public SCard_DivineSpirit() : base("Divine Spirit", 2) { TargetFixer fixer = (TargetObject x) => { (x as Monster).maxHp *= 2; (x as Monster).hp *= 2; }; needTargetAction = new NeedTargetAction((int pattern, TargetObject x) => x is Monster, fixer); chooseTargetAction = new ChooseTargetAction(needTargetAction); }
public SCard_AcraneExplosion() : base("Acrane Explosion", 2) { filter = (int pattern, TargetObject x) => { if ((pattern & Action.OPP) == 0) { return(false); } if ((pattern & Action.BOARD) == 0) { return(false); } return(x is Monster); }; fixer = (TargetObject x) => { (x as Monster).TakeDamage(1); }; }
public void UpdateAllTargetObject(int playerID, TargetFilter filter, TargetFixer updater) { Player.PublicInfo[] info = new Player.PublicInfo[] { player[0].GetPublicInfo(), player[1].GetPublicInfo() }; int[] playerPattern; if (player[0].ID == playerID) { playerPattern = new int[] { Action.SELF, Action.OPP } } ; else { playerPattern = new int[] { Action.OPP, Action.SELF } }; for (int i = 0; i < 2; ++i) { int facePattern = playerPattern[i] | Action.FACE; Player.Face face = info[i].face; if (filter(facePattern, face)) { updater(face); player[i].UpdateFace(face); } List <int> indices = new List <int>(); List <BoardObject> objs = new List <BoardObject>(); for (int j = 0; j < info[i].board.Count; ++j) { int boardPattern = playerPattern[i] | Action.BOARD | (j & Action.INDEX_MASK); BoardObject obj = info[i].board[j]; if (filter(boardPattern, obj)) { updater(obj); indices.Add(j); objs.Add(obj); } } if (indices.Count > 0) { player[i].UpdateBoard(indices, objs); } } } }
public void UpdateTargetObject(int playerID, int targetPattern, TargetObject target, TargetFixer updater) { updater(target); Player player = GetPlayer(playerID, (targetPattern & Action.SELF) != 0); if ((targetPattern & Action.FACE) != 0) { Player.Face f = target as Player.Face; if (f.hp <= 0) { winner = GetPlayer(player.ID, false); } player.UpdateFace(f); } if ((targetPattern & Action.BOARD) != 0) { player.UpdateBoard(targetPattern & Action.INDEX_MASK, target as BoardObject); } }
public AllTargetAction(TargetFilter filter, TargetFixer fixer) { this.filter = filter; this.fixer = fixer; }