2025-01-29 03:04:23 +01:00

80 lines
2.8 KiB
Plaintext

TopVar[0]
TopVar[1]
TopVar[2]
TopVar[3]
Vektator -> [0.. (2 byte index)
V
[t1_A, t1_B, t2_Z, t2_Y, t2_U]
// flottánként van a vektátor memóriaterület, ha túl sok, nem engedünk játszani
enum BYTEKIND
{
IGNORE,
NIL,
NUMBER,
INPUT,
OUTPUT,
OPCODE,
ENGINE,
HARDWARE,
COMM,
};
void f(game_state *gs, ship_tile *st, uint8_t byte_code[4], int byte_index);
bool validate(uint8_t *byte_code, byte_code_element *byte_info)
{
if (bk <= OUTPUT) return true;
bool ok = true;
for (int i = 1; i < 4; ++i)
{
switch(byte_info->at(i))
{
case IGNORE: return true;
case NUMBER: ok &= validate_number(byte_code[i]);
case OUTPUT: ok &= validate_variable(byte_code[i]);
case INPUT: ok &= (validate_number(byte_code[i]) || validate_variable(byte_code[i]));
case HARDWARE: ok &= hardwares.find(byte_code[i]) != hardwares.end();
}
}
return true;
}
#define LEVEL 0
{OPCODE, "HULL", 'H', hull, NUMBER, NUMBER, NUMBER}, // HULL <durability: 0..1> <energy gen> <energy store (between turns)> - first command
{OPCODE, "PAR", 'p', par, OUTPUT, NUMBER, NUMBER}, // PAR <persistant name> <low limit> <high limit> after HULL, before actual code
{OPCODE, "MUL", '*', mul},
{OPCODE, "ADD", '+', add},
{OPCODE, "ENGINE", 'e', nextbyte?, ENGINE, IGNORE, IGNORE},
{OPCODE, "HW", 'h', nextbyte?, HARDWARE, IGNORE, IGNORE},
{OPCODE, "COMM", 'c', nextbyte?, COMM, IGNORE, IGNORE},
#define LEVEL 1
// ENGINE - if multiple ones are set, we choose randomly from the options given
{ENGINE, "north", 'N', NIL, NIL, IGNORE},
{"east", 'E'},
{"west", 'W'},
{"south", 'S'},
// HARDWARE
{HARDWARE, "cannon", 'c', cannon, INPUT, INPUT, IGNORE}, // destroys target ("returns" bool)
{"sonar", 's'}, // shows tile + mine (radar)
{"tracer", 't'}, // ray-trace a line ("returns" bool), doesn't detect mines
{"jumbler", 'j'}, // randomizes parameters on target
{"disruptor", 'd'}, // counters cannons
{"mine", 'm'}, // places a mine (on your tile) that activates after P1 turns. When active and hit, it explodes
{"blow", 'b'}, // blows mines towards a line (move to the next tile that is hit by the line) (should start from the end, so multiple mines don't hit each other)
// COMM
{"write", 'w'}, // HW write <channel> <info> (write a number to a ship-wide channel)
{"read", 'r'}, // HW read <channel> <output> (read a number from a ship-wide channel)
{"gps", 'G'}, // HW gps <output_X> <output_Y> (gets global coordinates)
{"fwrite", 'W'}, // HW write <channel> <info> (write a number to a fleet-wide channel)
{"fread", 'R'}, // HW read <channel> <output> (read a number to a fleet-wide channel)
Anti-cheat (Peer-to-peer-re):
Mérjük a játékerejét a játékosnak külön hostként és kliensként. A kettő aránya ideális esetben 1. Ha kisebb, akkor 1-re felhozzuk. Az hostol, akinek ezután kisebb (vagy valami valószínűségi alapon)