/// <summary>马车格子数验证</summary> private bool CheckPacket(Int64 cid, tg_goods_business goods, int count) { var packetnum = 0; var businessgoods = tg_goods_business.GetListEntityByCid(cid); //马车上已有货物 if (businessgoods == null) { return(false); } if (goods != null) { var newgoodsinfo = businessgoods.FirstOrDefault(q => q.goods_id == goods.goods_id); if (newgoodsinfo != null) { newgoodsinfo.goods_number += count; //货物叠加 } } else { packetnum++; //新货物则格子+1 } foreach (var item in businessgoods) { var mun = RuleConvert.GetPacket(); packetnum += Convert.ToInt32(Math.Ceiling((double)item.goods_number / mun)); } var maxnum = tg_car.GetEntityById(cid).packet; return(packetnum <= maxnum); }
/// <summary>武将技能学习</summary> private ASObject RoleSkillLearn(TGGSession session, tg_role role, BaseFightSkill skill) { if (!string.IsNullOrEmpty(skill.studyCondition)) //验证所需前置技能信息 { var item = SkillData(skill.studyCondition); //获取前置技能集合信息 foreach (var id in item) { if (Convert.ToInt32(id) == 0) { continue; } var condition = tg_role_fight_skill.GetSkillByRidSkillId(role.id, Convert.ToInt32(id)); if (condition == null) { return(Result((int)ResultType.SKILL_CONDITION_LACK)); //验证前置技能 } if (condition.skill_level < skill.conditionLevel) { return(Result((int)ResultType.SKILL_CONDITION_LEVEL_LACK)); //验证前置技能等级 } } } if (role.role_level < skill.studyLevel) { return(Result((int)ResultType.BASE_ROLE_LEVEL_ERROR)); //验证武将等级 } var power = RuleConvert.GetCostPower(); //固定消耗体力 if (!Common.GetInstance().PowerOperate(role, power)) { return(Result((int)ResultType.BASE_ROLE_POWER_ERROR)); //验证体力 } return(LearningSkill(session, skill, role, power)); //学习过程处理 }
/// <summary>验证体力是否足够</summary> private bool CheckPower(tg_role role) { var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); return(totalpower >= power); }
/// <summary>消耗体力日志</summary> public void PowerLog(tg_role oldrole, int modulenumber, int command) { try { var cost = RuleConvert.GetCostPower(); var newrole = tg_role.GetRoleById(oldrole.id); if (newrole == null) { return; } var oldpower = tg_role.GetTotalPower(oldrole); string logdata; var s = GetCommandString(command); var m = GetModuleString(command); if (oldrole.role_state == (int)RoleStateType.PROTAGONIST) { var totalpower = tg_role.GetTotalPower(newrole); logdata = string.Format("{0}_{1}_{2}_{3}", "Power", oldpower, cost, totalpower); (new Log()).WriteLog(oldrole.user_id, (int)LogType.Use, modulenumber, command, m, s, "主角体力", (int)GoodsType.TYPE_POWER, cost, totalpower, logdata); } else { logdata = string.Format("{0}_{1}_{2}_{3}", "Power", oldpower, cost, newrole.power); (new Log()).WriteLog(oldrole.user_id, (int)LogType.Use, modulenumber, command, m, s, "武将体力", (int)GoodsType.TYPE_POWER, cost, newrole.power, logdata); } } catch (Exception ex) { XTrace.WriteException(ex); } }
/// <summary>获取最终武将攻击力</summary> /// <param name="model">武将信息</param> /// <returns></returns> public static Double GetTotalCritProbability(view_role model) { //魅力换算会心几率 (百分比) var total_cp = GetSingleTotal(RoleAttributeType.ROLE_CHARM, model); var c = RuleConvert.GetConvertAttribute(RoleAttributeType.ROLE_CHARM, total_cp); var total = c + model.att_crit_probability; return(total); }
/// <summary>获取最终武将会心效果 (百分比)</summary> /// <param name="model">武将信息</param> /// <returns></returns> public static Double GetTotalCritAddition(view_role model) { //政务换算会心效果 (百分比) var total_ca = GetSingleTotal(RoleAttributeType.ROLE_GOVERN, model); var c = RuleConvert.GetConvertAttribute(RoleAttributeType.ROLE_GOVERN, total_ca); var total = c + model.att_crit_addition; return(total); }
/// <summary>获取最终武将闪避几率(百分比)</summary> /// <param name="model">武将信息</param> public static Double GetTotalDodgeProbability(view_role model) { //智谋换算闪避几率 (百分比) var total_dp = GetSingleTotal(RoleAttributeType.ROLE_BRAINS, model); var c = RuleConvert.GetConvertAttribute(RoleAttributeType.ROLE_BRAINS, total_dp); var total = c + model.att_dodge_probability; return(total); }
/// <summary>获取最终武将奥义触发几率</summary> /// <param name="model">武将信息</param> public static Double GetTotalMysteryProbability(view_role model) { //统帅换算奥义触发几率 (百分比) var total_mp = GetSingleTotal(RoleAttributeType.ROLE_CAPTAIN, model); var c = RuleConvert.GetConvertAttribute(RoleAttributeType.ROLE_CAPTAIN, total_mp); var total = c + model.att_mystery_probability; return(total); }
/// <summary>获取最终武将攻击力</summary> /// <param name="model">武将信息</param> public static Double GetTotalAttack(view_role model) { //武力换算攻击力 var total_fo = GetSingleTotal(RoleAttributeType.ROLE_FORCE, model); var c = RuleConvert.GetConvertAttribute(RoleAttributeType.ROLE_FORCE, total_fo); var total = c + model.att_attack; return(total); }
/// <summary> /// 主角体力更新 /// </summary> /// <param name="iswin">战斗结果</param> /// <param name="role"></param> private void PowerUpdate(bool iswin, tg_role role) { if (!iswin) { return; } var power = RuleConvert.GetCostPower(); new Share.Role().PowerUpdateAndSend(role, power, role.user_id); }
public ASObject CommandStart(int goodType, TGGSession session, ASObject data) { try { #if DEBUG XTrace.WriteLine("{0}:{1}", "SKILL_FIGHT_UPGRADE", "战斗技能升级"); #endif var id = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "id").Value.ToString()); //战斗技能主键Id var skill = tg_role_fight_skill.GetBySkillId(id); if (skill == null) { return(Result((int)ResultType.DATABASE_ERROR)); //验证技能数据 } var role = tg_role.GetEntityById(skill.rid); if (role == null) { return(Result((int)ResultType.DATABASE_ERROR)); //验证武将数据 } if (skill.skill_state == (int)SkillLearnType.STUDYING) { return(Result((int)ResultType.FRONT_DATA_ERROR)); //验证技能状态信息 } if (tg_role_fight_skill.GetStudySkill(skill.rid, skill.skill_genre, (int)SkillLearnType.STUDYING)) //验证是否有其他正在学习或升级的技能 { return(Result((int)ResultType.SKILL_GENRE_HAS_LEARN)); } var baseskill = Variable.BASE_FIGHTSKILL.FirstOrDefault(m => m.id == skill.skill_id); //技能基表数据 if (baseskill == null) { return(Result((int)ResultType.BASE_TABLE_ERROR)); } if (skill.skill_level + 1 > baseskill.levelLimit) { return(Result((int)ResultType.SKILL_LEVEL_FALL)); //技能等级达到上限 } var nextskilleffect = Variable.BASE_FIGHTSKILLEFFECT.FirstOrDefault(m => m.skillid == skill.skill_id && m.level == skill.skill_level + 1); if (nextskilleffect == null) { return(Result((int)ResultType.BASE_TABLE_ERROR)); //下一等级战斗技能效果基表信息 } var power = RuleConvert.GetCostPower(); //固定消耗体力 if (!Common.GetInstance().PowerOperate(role, power)) { return(Result((int)ResultType.BASE_ROLE_POWER_ERROR)); //验证武将体力信息 } return(UpgradeSkill(session, nextskilleffect, skill, role, power)); } catch (Exception ex) { XTrace.WriteException(ex); return(new ASObject()); } }
/// <summary>体力操作</summary> public bool PowerOperate(tg_role role) { var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); if (totalpower < power) { return(false); } new Role().PowerUpdateAndSend(role, power, role.user_id); return(true); }
/// <summary>体力操作</summary> private bool PowerOperate(tg_role role, Int64 userid) { var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); if (totalpower < power) { return(false); } new Share.Role().PowerUpdateAndSend(role, power, userid); return(true); }
/// <summary>体力操作</summary> private bool PowerOperate(tg_role role, TGGSession session) { var userid = session.Player.User.id; var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); if (totalpower < power) { return(false); } new Share.Role().PowerUpdateAndSend(role, power, userid); return(true); }
/// <summary> 验证体力</summary> private bool CheckPower(tg_role role, TGGSession session) { var userid = session.Player.User.id; var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); if (totalpower >= power) { new Share.Role().PowerUpdateAndSend(role, power, userid); return(true); } result = (int)ResultType.BASE_ROLE_POWER_ERROR; return(false); }
/// <summary>体力操作</summary> private bool PowerOperate(tg_role role, Int64 userid) { var power = RuleConvert.GetCostPower(); var totalpower = tg_role.GetTotalPower(role); if (totalpower < power) { return(false); } var r = role.CloneEntity(); new Share.Role().PowerUpdateAndSend(role, power, userid); (new Share.Role()).LogInsert(r, power, ModuleNumber.WORK, (int)WorkCommand.WORK_ACCEPT, "工作", "接受工作 "); return(true); }
/// <summary> 购买体力 </summary> public ASObject Execute(Int64 userid, ASObject data) { var session = Variable.OnlinePlayer[userid] as TGGSession; if (session == null) { return(CommonHelper.ErrorResult((int)ResultType.FAIL)); } var player = session.Player.CloneEntity(); var mycount = player.UserExtend.power_buy_count; mycount++; //VIP购买体力次数验证 if (RuleConvert.GetBuyPower(player.Vip.vip_level) < mycount) { return(CommonHelper.ErrorResult((int)ResultType.VIP_POWER_ERROR)); } var baseinfo = Variable.BASE_BUYPOWER.FirstOrDefault(q => q.id == mycount); //读取基表数据 if (baseinfo == null) { return(BuildData((int)ResultType.BASE_TABLE_ERROR, 0)); } //够买次数已经达到上限 var maxpower = Variable.BASE_RULE.FirstOrDefault(q => q.id == "1009"); if (maxpower == null) { return(BuildData((int)ResultType.BASE_TABLE_ERROR, 0)); } if (player.User.gold < baseinfo.gold) { return(BuildData((int)ResultType.BASE_PLAYER_GOLD_ERROR, 0)); //金钱验证 } if (baseinfo.power + player.Role.Kind.power > Convert.ToInt32(maxpower.value)) //最大体力数验证 { return(BuildData((int)ResultType.ROLE_POWER_OVER, 0)); } GoldSaveAndSend(player.User, baseinfo, userid); //保存金币数据 PowerSaveAndSend(player.Role.Kind, baseinfo.power, userid); //保存体力数据 player.UserExtend.power_buy_count = mycount; player.UserExtend.Save(); session.Player = player; return(BuildData((int)ResultType.SUCCESS, mycount)); }
public ASObject CommandStart(TGGSession session, ASObject data) { try { #if DEBUG XTrace.WriteLine("{0}:{1}", "SINGLE_FIGHT_NPC", "一将讨挑战"); #endif var npcid = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "id").Value.ToString()); var mainrole = session.Player.Role.Kind; var basenpc = Variable.BASE_NPCSINGLE.FirstOrDefault(m => m.id == npcid); if (basenpc == null) { return(Result((int)ResultType.BASE_TABLE_ERROR)); //验证基表信息 } var cost = RuleConvert.GetCostPower(); //固定消耗体力 if (!CheckPower(mainrole, cost)) { return(Result((int)ResultType.BASE_ROLE_POWER_ERROR)); } var fight = NpcChallenge(session.Player.User.id, npcid, FightType.SINGLE_FIGHT); //获得战斗结果Vo if (fight == null) { return(Result((int)ResultType.FIGHT_ERROR)); //验证战斗是否出错 } //判断挑战结果信息 return(ChallengeResult(session, basenpc.prop, basenpc.count, fight, cost)); } catch (Exception ex) { XTrace.WriteException(ex); return(new ASObject()); } }