public override EventWitness getWitness(TouhouCardEngine.CardEngine engine, Player player) { EventWitness witness = new InitWitness(); //双方玩家所使用的卡组主人公 witness.setVar("masterCardsRID", engine.getPlayers().Select(p => { return(p["Master"][0].id); }).ToArray()); witness.setVar("masterCardsDID", engine.getPlayers().Select(p => { return(p["Master"][0].define.id); }).ToArray()); //双方玩家所使用的技能 witness.setVar("skillCardsRID", engine.getPlayers().Select(p => { return(p["Skill"][0].id); }).ToArray()); witness.setVar("skillCardsDID", engine.getPlayers().Select(p => { return(p["Skill"][0].define.id); }).ToArray()); //然后是玩家的先后行动顺序 witness.setVar("sortedPlayersIndex", engine.getProp <Player[]>("sortedPlayers").Select(p => { return(engine.getPlayerIndex(p)); }).ToArray()); //接着是初始手牌 witness.setVar("initCardsRID", engine.getPlayers().Select(p => { return(p["Init"].Select(c => { return c.id; }).ToArray()); }).ToArray()); witness.setVar("initCardsDID", player["Init"].Select(e => { return(e.define.id); }).ToArray()); //剩余卡组 witness.setVar("deck", player["Deck"].OrderBy(c => { return(c.define.id); }).Select(c => { return(c.define.id); }).ToArray()); return(witness); }
public override void execute(TouhouCardEngine.CardEngine engine) { //决定玩家行动顺序 List <Player> remainedList = new List <Player>(engine.getPlayers()); Player[] sortedPlayers = new Player[remainedList.Count]; for (int i = 0; i < sortedPlayers.Length; i++) { int index = engine.randomInt(0, remainedList.Count - 1); sortedPlayers[i] = remainedList[index]; remainedList.RemoveAt(index); } engine.setProp("sortedPlayers", sortedPlayers); //创建主人公和技能卡 Card[] masterCards = sortedPlayers.Select(p => { return(p["Master"][0]); }).ToArray(); foreach (Card card in masterCards) { card.setProp("life", 10); engine.registerCard(card); } Card[] skillCards = sortedPlayers.Select(p => { return(p["Skill"][0]); }).ToArray(); foreach (Card card in skillCards) { engine.registerCard(card); } //洗牌,然后抽初始卡牌 for (int i = 0; i < sortedPlayers.Length; i++) { if (engine.getProp <bool>("shuffle")) { sortedPlayers[i]["Deck"].shuffle(engine); } int count = i == 0 ? 3 : 4; Card[] cards = sortedPlayers[i]["Deck"][sortedPlayers[i]["Deck"].count - count, sortedPlayers[i]["Deck"].count - 1]; sortedPlayers[i]["Deck"].moveTo(cards, sortedPlayers[i]["Init"], 0); engine.registerCards(cards); } }