예제 #1
0
        BattleResult AttackProvince(string factionId, string provinceId)
        {
            Province province             = GetProvince(provinceId);
            string   oldProvinceFactionId = province.FactionId;

            BattleResult result = attack.AttackProvince(factionId, provinceId);

            if (GetRelation(factionId, oldProvinceFactionId).Value > 0)
            {
                world.SetRelations(factionId, oldProvinceFactionId, 0);
            }

            if (result == BattleResult.Victory)
            {
                world.ChangeRelations(factionId, oldProvinceFactionId, -10);
            }

            switch (province.Type)
            {
            case ProvinceType.Capital:
                world.ChangeRelations(factionId, oldProvinceFactionId, -10);
                break;

            case ProvinceType.Province:
                world.ChangeRelations(factionId, oldProvinceFactionId, -5);
                break;
            }

            switch (province.State)
            {
            case ProvinceState.Sovereign:
                world.ChangeRelations(factionId, oldProvinceFactionId, -5);
                break;

            case ProvinceState.Occupied:
                world.ChangeRelations(factionId, oldProvinceFactionId, -2);
                break;
            }

            if (oldProvinceFactionId == PlayerFactionId)
            {
                BattleEventArgs e = new BattleEventArgs(provinceId, factionId, result);

                if (PlayerProvinceAttacked != null)
                {
                    PlayerProvinceAttacked(this, e);
                }
            }

            return(result);
        }