示例#1
0
 /// <summary>
 /// 验证该武将是否在该城市中
 /// </summary>
 /// <param name="role">合战武将实体</param>
 /// <returns></returns>
 private bool CheckRoleState(tg_war_role role)
 {
     if (role == null)
     {
         return(false);
     }
     if (!tg_war_role.RoleIsIdle(role))
     {
         return(false);
     }
     role.state = (int)WarRoleStateType.DEFENSE;
     role.Update();
     new Share.War().SendWarRole(role, "state");
     return(true);
 }
示例#2
0
        /// <summary> 保存武将合战状态并推送 </summary>
        /// <param name="role">要保存的武将实体</param>
        /// <param name="state">要更改的状态</param>
        /// <param name="id">固定规则id</param>
        public void SaveRoleStateAndSend(tg_war_role role, int state, string id)
        {
            var rv = Variable.BASE_RULE.FirstOrDefault(m => m.id == id);

            if (rv == null)
            {
                return;
            }
            var count = 0;

            #region 外交冷却时间减少

            if (state == (int)WarRoleStateType.DIPLOMATIC_RELATIONS)
            {
                count = Convert.ToInt32((new Share.War()).GetTactics(role.user_id, (int)WarTacticsType.FOREIGN_TIME)); //内政策略外交冷却时间减少
            }

            #endregion

            var value = Convert.ToInt32(rv.value) - count;
            value               = value < 0 ? 0 : value;
            role.state          = state;
            role.state_end_time = (DateTime.Now.AddMinutes(value).Ticks - 621355968000000000) / 10000;

#if DEBUG
            role.state_end_time = (DateTime.Now.AddMinutes(1).Ticks - 621355968000000000) / 10000;
#endif
            role.Update();
            (new Share.War()).TaskRoleState(role);

            var str = new string[] { "state" };
            if (Convert.ToInt32(WarRoleStateType.PRISONERS) == state)
            {
                str = new string[] { "state", "stateEndTime" }
            }
            ;

            (new Share.War()).SendWarRole(role, str); //推送武将合战状态更变
        }
示例#3
0
        private bool SavaData(List <Common.Resourse> resourses, tg_war_role role, Int32 baseid, Int32 count, tg_war_city city)
        {
            role.army_id      = baseid;
            role.army_soldier = count;
            //更新城市资源和武将资源
            foreach (var resourse in resourses)
            {
                switch (resourse.type)
                {
                case (int)WarResourseType.兵粮: { city.res_foods -= resourse.value * count; } break;

                case (int)WarResourseType.军资金: { city.res_funds -= resourse.value * count; } break;

                case (int)WarResourseType.苦无: { city.res_use_kuwu += resourse.value * count; role.army_kuwu = resourse.value * count; } break;

                case (int)WarResourseType.薙刀: { city.res_use_razor += resourse.value * count; role.army_razor = resourse.value * count; } break;

                case (int)WarResourseType.足轻: { city.res_use_soldier += resourse.value * count; role.army_soldier = resourse.value * count; } break;

                case (int)WarResourseType.铁炮: { city.res_use_gun += resourse.value * count; role.army_gun = resourse.value * count; } break;

                case (int)WarResourseType.马匹: { city.res_use_horse += resourse.value * count; role.army_horse = resourse.value * count; } break;
                }
            }
            //保存数据
            role.Update();
            city.Update();
            Variable.WarCityAll.TryUpdate(city.base_id, city, city);
            //推送数据
            var list = new[] { "armyBaseId", "armyCount" };

            new Share.War().SendWarRole(role, list);
            new Share.War().SendCity(city.base_id, role.user_id);
            //tg_war_city.Update(string.Format("res_use_foods={0},res_use_funds={1},res_use_kuwu={2},res_use_razor={3}," +
            //                                 "res_use_soldier={4},res_use_gun={5},res_use_horse={6}"city.res_use_foods, city.res_use_funds))
            return(true);
        }