Exemplo n.º 1
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var proponentSlot = args[0].AsSlot();
     var opponentSlot = 255 - args[1].AsSlot();
     var n = args[2].AsNum();
     if (me[proponentSlot].vitality < n) throw new GameError("not enough vitality " + me[proponentSlot].vitality + " for " + this);
     me[proponentSlot].vitality -= n;
     if (opponent[opponentSlot].vitality > 0)
     {
         if (!zombieMode)
         {
             opponent[opponentSlot].vitality -= n*9/10;
             if (opponent[opponentSlot].vitality < 0) opponent[opponentSlot].vitality = 0;
         }
         else
         {
             opponent[opponentSlot].vitality += n * 9 / 10;
             if (opponent[opponentSlot].vitality > 65535) opponent[opponentSlot].vitality = 65535;
         }
     }
     return Funcs.I;
 }
Exemplo n.º 2
0
 public Move(Value card, int slot)
 {
     this.slot = slot;
     this.card = card;
     card_to_slot = true;
 }
Exemplo n.º 3
0
 public Move(int slot, Value card)
 {
     this.slot = slot;
     this.card = card;
     card_to_slot = false;
 }
Exemplo n.º 4
0
 private static void Apply(Slot[] me, Slot[] opponent, Value left, Value right, int resultSlot)
 {
     RessurectZombies(me, opponent);
     try
     {
         if (me[resultSlot].vitality <= 0) throw new GameError("result slot is dead:" + resultSlot);
         if (left.ArgsNeeded <= 0) throw new GameError("incorrect application: " + left + " " + right);
         var applicationsDone = 0;
         var res = new Application(left, right).Reduce(me, opponent, ref applicationsDone, false);
         me[resultSlot].value = res;
     }
     catch (GameError e)
     {
         Log(e.Message);
         me[resultSlot].value = Funcs.I;
     }
 }
Exemplo n.º 5
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var opponentSlot = 255 - args[0].AsSlot();
     var x = args[1];
     if (opponent[opponentSlot].vitality > 0) throw new GameError("Slot is not dead! " + this);
     opponent[opponentSlot].value = x;
     opponent[opponentSlot].vitality = -1;
     return Funcs.I;
 }
Exemplo n.º 6
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var f = args[0];
     var g = args[1];
     var x = args[2];
     var left = new Application(f, x).Reduce(me, opponent, ref applicationsDone, zombieMode);
     var right = new Application(g, x).Reduce(me, opponent, ref applicationsDone, zombieMode);
     var res = new Application(left, right).Reduce(me, opponent, ref applicationsDone, zombieMode);
     return res;
 }
Exemplo n.º 7
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var arg = args.First();
     if (arg is Num) return new Num(Math.Min(((Num)arg).num + 1, 65535));
     throw new GameError("Call succ with not a num: " + arg);
 }
Exemplo n.º 8
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     return Funcs.I;
 }
Exemplo n.º 9
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var proponentSlot = args[0].AsSlot();
     if (me[proponentSlot].vitality <= 0)
         me[proponentSlot].vitality = 1;
     return Funcs.I;
 }
Exemplo n.º 10
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     var slot = args.First().AsSlot();
     var vitality = me[slot].vitality;
     if (!zombieMode)
     {
         if (vitality > 0 && vitality < 65535)
             me[slot].vitality = vitality + 1;
     }
     else
     {
         if (vitality > 0)
             me[slot].vitality = vitality - 1;
     }
     return Funcs.I;
 }
Exemplo n.º 11
0
 public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     return me[args.First().AsSlot()].value;
 }
Exemplo n.º 12
0
 public Value Reduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode)
 {
     if (args.Length != ArgsNeeded) throw new Exception("Bug in code!");
     if (applicationsDone >= 1000) throw new GameError("Too many applications " + applicationsDone);
     applicationsDone++;
     //r.Append(" " + ToString());
     var res = DoReduce(me, opponent, args, ref applicationsDone, zombieMode);
     return res;
 }
Exemplo n.º 13
0
 public abstract Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode);
Exemplo n.º 14
0
 public Application(Value f, Value arg)
     : base(f.ArgsNeeded - 1, () => string.Format("{0}({1})", f, arg))
 {
     this.f = f;
     this.arg = arg;
 }