Sanguosha.Core.Network.SkillItem.Parse C# (CSharp) 메소드

Parse() 공개 정적인 메소드

public static Parse ( ISkill skill ) : SkillItem
skill ISkill
리턴 SkillItem
        public static SkillItem Parse(ISkill skill)
        {
            if (skill == null) return null;
            SkillItem result;
            if (skill is CheatSkill)
            {
                CheatSkillItem csi = new CheatSkillItem();
                CheatSkill cs = skill as CheatSkill;
                result = csi;
                csi.CardId = cs.CardId;
                csi.CheatType = (int)cs.CheatType;
                csi.SkillName = cs.SkillName;
            }
            else if (skill is IAdditionalTypedSkill)
            {
                var atsi = new AdditionalTypedSkillItem();
                var ats = skill as IAdditionalTypedSkill;
                result = atsi;
                atsi.AdditionalTypeId = GameEngine.Serialize(ats.AdditionalType);
            }
            else
            {
                result = new SkillItem();
            }

            result.PlayerItem = PlayerItem.Parse(skill.Owner);
            if (skill.Owner != null)
            {
                result.SkillId = (byte)skill.Owner.ActionableSkills.IndexOf(skill);
            }
            return result;
        }

Usage Example

예제 #1
0
        public static AskForCardUsageResponse Parse(int id, ISkill skill, List <Card> cards, List <Player> players, int wrtPlayerId)
        {
            AskForCardUsageResponse response = new AskForCardUsageResponse();

            response.Id        = id;
            response.SkillItem = SkillItem.Parse(skill);
            if (cards == null)
            {
                response.CardItems = null;
            }
            else
            {
                response.CardItems = new List <CardItem>();
                foreach (var card in cards)
                {
                    response.CardItems.Add(CardItem.Parse(card, wrtPlayerId));
                }
            }
            if (players == null)
            {
                response.PlayerItems = null;
            }
            else
            {
                response.PlayerItems = new List <PlayerItem>();
                foreach (var player in players)
                {
                    response.PlayerItems.Add(PlayerItem.Parse(player));
                }
            }
            return(response);
        }