Beispiel #1
0
        public void SetEnemyAnger(int fieldId, int anger)
        {
            if (m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.EmptyGray || m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.Empty || m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.RewardGray)
            {
                return;
            }
            BattleChessField target = m_Chess.ChessBoard[fieldId] as BattleChessField;

            target.EnemyAnger = anger;
        }
Beispiel #2
0
        public void SetEnemyStatus(int fieldId, List <int> status)
        {
            if (m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.EmptyGray || m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.Empty || m_Chess.ChessBoard[fieldId].Color == ChessFieldColor.RewardGray)
            {
                return;
            }
            BattleChessField target = m_Chess.ChessBoard[fieldId] as BattleChessField;

            for (int i = 0; i < status.Count; i++)
            {
                target.EnemyHeroHP[i] = status[i];
            }
        }
Beispiel #3
0
        public static BattleChessField GetBattleChessField(ChessFieldColor color, int enemyId, int count)
        {
            BattleChessField field = new BattleChessField();

            field.Color         = color;
            field.IsOpened      = false;
            field.Count         = count;
            field.EnemyAnger    = 0;
            field.EnemyPlayerId = enemyId;
            HeroTeamLogic heroTeam = new HeroTeamLogic();

            heroTeam.SetUser(field.EnemyPlayerId);
            PlayerHeroLogic playerHero = new PlayerHeroLogic();

            playerHero.SetUser(field.EnemyPlayerId);
            int i = 0;

            foreach (int heroId in heroTeam.MyHeroTeam.Team)
            {
                if (heroId == 0)
                {
                    break;
                }
                field.EnemyPlayerHeroTeam[i]                    = new Hero();
                field.EnemyPlayerHeroTeam[i].HeroType           = playerHero.MyHeros.Heros[heroId].HeroType;
                field.EnemyPlayerHeroTeam[i].HeroLv             = playerHero.MyHeros.Heros[heroId].HeroLv;
                field.EnemyPlayerHeroTeam[i].HeroStarLevel      = playerHero.MyHeros.Heros[heroId].HeroStarLevel;
                field.EnemyPlayerHeroTeam[i].ElevationLevel     = playerHero.MyHeros.Heros[heroId].ElevationLevel;
                field.EnemyPlayerHeroTeam[i].ConsciousnessLevel = playerHero.MyHeros.Heros[heroId].ConsciousnessLevel;
                field.EnemyPlayerHeroTeam[i].Gears              = new CacheDictionary <GearType, int>();
                field.EnemyPlayerHeroTeam[i].SkillLevels.AddRange(playerHero.MyHeros.Heros[heroId].SkillLevels);
                foreach (var gear in playerHero.MyHeros.Heros[heroId].Gears)
                {
                    field.EnemyPlayerHeroTeam[i].Gears[gear.Key] = gear.Value;
                }
                field.EnemyPlayerHeroTeam[i].Souls = new CacheDictionary <int, int>();
                foreach (var soul in playerHero.MyHeros.Heros[heroId].Souls)
                {
                    field.EnemyPlayerHeroTeam[i].Souls[soul.Key] = soul.Value;
                }
                //field.EnemyHeroHP.Add(MaxHP);
                i++;
            }
            return(field);
        }
Beispiel #4
0
        public Dictionary <int, int> BombAll(out int coin, out int money, out int starEnergy)
        {
            coin       = 0;
            money      = 0;
            starEnergy = 0;
            Dictionary <int, int> rewardItems = new Dictionary <int, int>();

            m_Chess.Count = 0;
            int totalCost   = 0;
            int OpenedCount = 0;

            foreach (var chessField in m_Chess.ChessBoard)
            {
                if ((chessField.Color == ChessFieldColor.EmptyGray || chessField.Color == ChessFieldColor.RewardGray || chessField.Color == ChessFieldColor.Empty))
                {
                    if (!chessField.IsOpened)
                    {
                        totalCost += GetOpenCost(OpenedCount++);
                    }
                }
            }
            PlayerLogic p = new PlayerLogic();

            p.SetUser(m_UserId);
            if (!p.DeductMoney(totalCost))
            {
                return(null);
            }
            foreach (var chessField in m_Chess.ChessBoard)
            {
                if ((chessField.Color == ChessFieldColor.EmptyGray || chessField.Color == ChessFieldColor.RewardGray || chessField.Color == ChessFieldColor.Empty))
                {
                    if (!chessField.IsOpened)
                    {
                        RewardChessField rewardField = chessField as RewardChessField;
                        foreach (var reward in rewardField.RewardItems)
                        {
                            if (rewardItems.ContainsKey(reward.Key))
                            {
                                rewardItems[reward.Key] += reward.Value;
                            }
                            else
                            {
                                rewardItems.Add(reward.Key, reward.Value);
                            }
                        }
                    }
                }
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            pp.CheckPackageSlot(rewardItems);
            foreach (var chessField in m_Chess.ChessBoard)
            {
                if ((chessField.Color == ChessFieldColor.EmptyGray || chessField.Color == ChessFieldColor.RewardGray || chessField.Color == ChessFieldColor.Empty))
                {
                    if (!chessField.IsOpened)
                    {
                        RewardChessField rewardField = chessField as RewardChessField;
                        coin                += rewardField.RewardCoin;
                        money               += rewardField.RewardMoney;
                        starEnergy          += rewardField.RewardStarEnergy;
                        rewardField.IsOpened = true;
                        rewardField.ParentId = -1;
                    }
                }
                else
                {
                    BattleChessField battleField = chessField as BattleChessField;
                    battleField.ChildrenId = new CacheList <int>();
                }
            }
            return(rewardItems);
        }
Beispiel #5
0
        public override bool TakeAction()
        {
            PlayerChessLogic playerChess = new PlayerChessLogic();

            playerChess.SetUser(m_UserId);
            if (!(playerChess.MyChess.ChessBoard[m_RequestPacket.ChessFieldIndex] is BattleChessField))
            {
                m_ResponsePacket.Success = false;
                return(true);
            }
            BattleChessField targetField = playerChess.MyChess.ChessBoard[m_RequestPacket.ChessFieldIndex] as BattleChessField;

            m_ResponsePacket.Anger = targetField.EnemyAnger;
            PlayerLogic player = new PlayerLogic();

            player.SetUser(targetField.EnemyPlayerId);
            m_ResponsePacket.EnemyInfo = new PBPlayerInfo()
            {
                Id    = player.MyPlayer.Id,
                Name  = player.MyPlayer.Name,
                Level = player.MyPlayer.Level,
                Might = player.MyPlayer.Might,
            };
            GearLogic gearlogic = new GearLogic();
            int       i         = 0;

            foreach (var hero in targetField.EnemyPlayerHeroTeam)
            {
                PBLobbyHeroInfo enemyHero = new PBLobbyHeroInfo()
                {
                    Type               = hero.HeroType,
                    Level              = hero.HeroLv,
                    StarLevel          = hero.HeroStarLevel,
                    ConsciousnessLevel = hero.ConsciousnessLevel,
                    ElevationLevel     = hero.ElevationLevel,
                };
                enemyHero.SkillLevels.AddRange(hero.SkillLevels);

                foreach (var gear in hero.Gears)
                {
                    gearlogic.SetGear(gear.Value);
                    PBGearInfo enemyGear = new PBGearInfo()
                    {
                        Id    = gearlogic.MyGear.Id,
                        Type  = gearlogic.MyGear.TypeId,
                        Level = gearlogic.MyGear.Level
                    };
                    enemyHero.GearInfo.Add(enemyGear);
                }
                if (targetField.EnemyHeroHP.Count > i)
                {
                    PBLobbyHeroStatus enemyStatus = new PBLobbyHeroStatus()
                    {
                        Type  = hero.HeroType,
                        CurHP = targetField.EnemyHeroHP[i]
                    };
                    m_ResponsePacket.HeroesStatus.Add(enemyStatus);
                }
                m_ResponsePacket.HeroesInfo.Add(enemyHero);
                m_ResponsePacket.ChessFieldIndex = m_RequestPacket.ChessFieldIndex;
                i++;
            }
            m_ResponsePacket.Success = true;
            return(true);
        }
Beispiel #6
0
        private bool RefreshData(PlayerChessLogic playerChess)
        {
            int         costFieldCount     = 0;
            int         freeFieldCount     = 0;
            int         totalCostFreeCount = 0;
            Transaction t = new Transaction();

            t.DumpEntity(playerChess.MyChess);
            PlayerPackageLogic package = new PlayerPackageLogic();

            package.SetUser(m_UserId);
            foreach (var field in m_RequestPacket.ModifiedChessField)
            {
                var oldField = playerChess.MyChess.ChessBoard[field.Index];
                int oldColor = oldField.Color == ChessFieldColor.Empty || oldField.Color == ChessFieldColor.EmptyGray || oldField.Color == ChessFieldColor.RewardGray ?
                               (int)ChessFieldColor.EmptyGray : (int)oldField.Color;
                if (field.Color != oldColor)
                {
                    t.RollBack();
                    ErrorCode = (int)ErrorType.CannotOpenChance;
                    ErrorInfo = "illegal params";
                    return(false);
                }
                if (field.Color == (int)ChessFieldColor.EmptyGray)
                {
                    RewardChessField oldRewardField = oldField as RewardChessField;
                    if (!oldRewardField.IsOpened && field.IsOpened)
                    {
                        if (!oldRewardField.IsFree)
                        {
                            if (m_RequestPacket.ModifiedChessField.Count == 1)
                            {
                                costFieldCount += 1;
                            }
                            else
                            {
                                freeFieldCount += 1;
                            }
                        }
                        else
                        {
                            freeFieldCount += 1;
                        }
                        m_GotCoin       += oldRewardField.RewardCoin;
                        m_GotMoney      += oldRewardField.RewardMoney;
                        m_GotStarEnergy += oldRewardField.RewardStarEnergy;
                        foreach (var reward in oldRewardField.RewardItems)
                        {
                            if (m_GotItems.ContainsKey(reward.Key))
                            {
                                m_GotItems[reward.Key] += reward.Value;
                            }
                            else
                            {
                                m_GotItems.Add(reward);
                            }
                        }
                        PlayerPackageLogic pp = new PlayerPackageLogic();
                        pp.SetUser(m_UserId);
                        if (!pp.CheckPackageSlot(m_GotItems))
                        {
                            ErrorCode = (int)ErrorType.PackageSlotFull;
                            ErrorInfo = "item count if full";
                            return(false);
                        }
                        playerChess.DeductOpenCount();
                    }
                    oldRewardField.IsFree   = field.IsFree;
                    oldRewardField.IsOpened = field.IsOpened;
                    oldRewardField.ParentId = field.Parent;
                }
                else
                {
                    BattleChessField oldBattleField = oldField as BattleChessField;
                    if (!oldBattleField.IsOpened && field.IsOpened)
                    {
                        m_ResponsePacket.FreeCount = oldBattleField.Count;
                        costFieldCount            += 1;
                        oldBattleField.IsOpened    = field.IsOpened;
                        PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.WinTurnOverChessBattle, 1);
                    }
                    else
                    {
                        if (field.FreeCount < 0 || field.FreeCount > oldBattleField.Count)
                        {
                            ErrorCode = (int)ErrorType.CannotOpenChance;
                            ErrorInfo = "illegal params";
                            return(false);
                        }
                        totalCostFreeCount  += oldBattleField.Count - field.FreeCount;
                        oldBattleField.Count = field.FreeCount;
                    }
                    oldBattleField.ChildrenId.AddRange(field.Children);
                }
            }
            if (freeFieldCount != totalCostFreeCount)
            {
                t.RollBack();
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "illegal params";
                return(false);
            }
            if (costFieldCount > 1)
            {
                t.RollBack();
                ErrorCode = (int)ErrorType.CannotOpenChance;
                ErrorInfo = "illegal params";
                return(false);
            }
            playerChess.MyChess.Count -= costFieldCount;
            return(true);
        }