// remove hero-spec RIM/RTM Diva, hero = 0 means removing all public static void ErasePlayerToken(Player player, Board board, Action<string> raiseG, int hero = 0) { if (player.TokenCount != 0) raiseG("G0OJ," + player.Uid + ",0," + player.TokenCount); if (player.TokenExcl.Count > 0) { char exclType = player.TokenExcl[0][0]; Card.Genre exclGenre = Card.Char2Genre(exclType); ushort[] cards = player.TokenExcl.Select(p => ushort.Parse(p.Substring(1))).ToArray(); raiseG("G2TZ,0," + player.Uid + "," + string.Join(",", player.TokenExcl)); raiseG("G0OJ," + player.Uid + ",1," + Algo.ListToString(player.TokenExcl)); if (Algo.Include(exclGenre, Card.Genre.Tux, Card.Genre.NMB, Card.Genre.Eve)) raiseG(new Abandon() { Zone = CustomsHelper.ZoneType.PLAYER, Genre = exclGenre, SingleUnit = new CustomsUnit() { Source = player.Uid, Cards = cards } }.ToMessage()); } if (player.TokenTars.Count > 0) raiseG("G0OJ," + player.Uid + ",2," + player.TokenTars.Count + "," + string.Join(",", player.TokenTars)); if (player.TokenAwake) raiseG("G0OJ," + player.Uid + ",3"); if (player.TokenFold.Count > 0) { List<ushort> folds = player.TokenFold.ToList(); raiseG("G2TZ,0," + player.Uid + "," + string.Join(",", folds.Select(p => "C" + p))); raiseG("G0OJ," + player.Uid + ",4," + folds.Count + "," + string.Join(",", folds)); raiseG(new Abandon() { Zone = CustomsHelper.ZoneType.PLAYER, Genre = Card.Genre.Tux, SingleUnit = new CustomsUnit() { Source = player.Uid, Cards = folds.ToArray() } }.ToMessage()); } player.ResetROM(board, hero); // Remove others' tar token on the player foreach (Player py in board.Garden.Values) { if (py.IsAlive && py != player && py.TokenTars.Contains(player.Uid)) raiseG("G0OJ," + py.Uid + ",2,1," + player.Uid); } }
// judge whether the fuse is matched public static bool IsFuseMatch(string rawFuse, string fuse, Board board) { string r = board.Rounder.Uid.ToString(); fuse = Algo.Substring(fuse, 0, fuse.IndexOf(',')); return rawFuse == fuse || (rawFuse.Replace("#", r) == fuse) || board.Garden.Keys.Any(p => p != board.Rounder.Uid && rawFuse.Replace("$", r) == fuse) || board.Garden.Keys.Any(p => rawFuse.Replace("*", r) == fuse); }
// check whether $player's $linkHead is suitable for $tux, then return the pureType public static int GetTuxTypeFromLink(string linkFuse, Tux tux, Player player, Board board, out string pureFuse) { return GetTuxTypeFromLink(linkFuse, tux, player, player, board, out pureFuse); }
// check whether $player's $linkHead is suitable for $tux, then return the pureType public static int GetTuxTypeFromLink(string linkFuse, Tux tux, Player provider, Player user, Board board, out string pureFuse) { int idx = linkFuse.IndexOf(":"); pureFuse = linkFuse.Substring(idx + 1); if (tux == null || idx <= 0) return -1; string[] linkHeads = Algo.Substring(linkFuse, 0, idx).Split('&'); foreach (string linkHead in linkHeads) { string[] lh = linkHead.Split(','); string pureName = lh[0], pureTypeStr = lh[1], rawOc = lh[2]; if (!pureTypeStr.Contains("!") && IsFuseMatch(rawOc, pureFuse, board)) { int pureType = int.Parse(pureTypeStr); if (tux.Code == pureName && tux.Bribe(provider, pureType, pureFuse) && tux.Valid(user, pureType, pureFuse)) return pureType; } } return -1; }
// check whether $player's $linkHead is suitable for $tux, not consider the pureFuse public static int GetTuxTypeFromLink(string linkFuse, Tux tux, Player provider, Player user, Board board) { string pureFuse; return GetTuxTypeFromLink(linkFuse, tux, provider, user, board, out pureFuse); }