static public async Task ActAsync(TargetSpaceCtx ctx) { // if you have 2 sun, 2 air, 2 animal, // First Gather up to 3 dahan if (await ctx.YouHave("2 sun,2 air,2 animal")) { await ctx.GatherUpToNDahan(3); } // move up to 5 dahan from target land to any land. Space destination = await ctx.MoveTokensOut(max : 5, TokenType.Dahan, range : 100); // defend 5 in that land if (destination != null) { ctx.Target(destination).Defend(5); } }
static async Task MoveDahanAction(TargetSpaceCtx ctx) { int count = 2; while (0 < count) { var costalCtxs = ctx.AllSpaces.Select(ctx.Target).Where(x => x.IsCoastal).ToArray(); var costalWithDahan = costalCtxs.Where(x => x.Dahan.Any).ToArray(); var costal = costalCtxs.Select(x => x.Space).ToArray(); await ctx.SelectActionOption( new SpaceAction($"Move Dahan IN TO " + ctx.Space.Label, ctx => ctx.MoveTokenIn(TokenType.Dahan, 100, Target.Coastal)).FilterOption(costalWithDahan.Length > 0), new SpaceAction($"Move Dahan OUT OF " + ctx.Space.Label, ctx => ctx.MoveTokensOut(1, TokenType.Dahan, 100, Target.Coastal)).Matches(x => x.Dahan.Any) ); count--; } }
static public async Task MoveBeastAndFriends(TargetSpaceCtx ctx, int steps) { if (steps <= 0) { return; } // move beast Space destination = await ctx.MoveTokensOut(1, TokenType.Beast, 1); if (destination == null) { return; } // As it moves, up to 2 dahan may move with it, for part or all of the way. // the beast / dahan may move to an adjacent land and then back. var destCtx = ctx.Target(destination); await new GatherDahanFromSingle(destCtx, ctx.Space) .AddGroup(2, TokenType.Dahan) .GatherUpToN(); await MoveBeastAndFriends(destCtx, steps - 1); }