public static GameContextOutput Output(this GameContext gameContext) { GameContextOutput gameContextOutput = new GameContextOutput() { GameCode = gameContext.GameCode, TurnIndex = gameContext.TurnIndex, CastCardCount = gameContext.CastCardCount, CurrentTurnCode = gameContext.CurrentTurnCode, CurrentTurnRemainingSecond = gameContext.CurrentTurnRemainingSecond, DeskCards = gameContext.DeskCards, NextTurnCode = gameContext.NextTurnCode, }; foreach (var cd in gameContext.Players) { if (cd.IsActivation) { gameContextOutput.Players.Add(new UserContextOutput() { HandCards = cd.HandCards.ToList(), InitCards = cd.InitCards.ToList(), IsActivation = cd.IsActivation, IsFirst = cd.IsFirst, Power = cd.Power, StockCards = cd.StockCards.Count(), SwitchDone = cd.SwitchDone, UserCode = cd.UserCode, TurnIndex = gameContext.TurnIndex, FullPower = cd.FullPower, Hero = gameContext.GetHeroByActivation(cd.IsActivation), }); } else { gameContextOutput.Players.Add(new UserContextSimpleOutput() { HandCards = cd.HandCards.Count(), InitCards = cd.InitCards.Count(), IsActivation = cd.IsActivation, IsFirst = cd.IsFirst, Power = cd.Power, StockCards = cd.StockCards.Count(), SwitchDone = cd.SwitchDone, UserCode = cd.UserCode, TurnIndex = gameContext.TurnIndex, FullPower = cd.FullPower, Hero = gameContext.GetHeroByActivation(cd.IsActivation), }); } } return(WriteGameStatus(gameContext, gameContextOutput)); }
public static GameContextOutput WriteGameStatus(this GameContext gameContext, GameContextOutput gameContextOutput) { gameContextOutput.GameStatus = gameContext.GameStatus; return(gameContextOutput); }