internal void DealWithReduceWhenAttack(interfaceOfHM.AttackT at, RoleInGame player, Car car, RoleInGame victim, long percentValue, ref List <string> notifyMsg, out long reduce, long m, ref long reduceSum) { var attackMoneyBeforeDefend = (at.leftValue(car.ability) * (100 - at.GetDefensiveValue(victim.getCar().ability.driver)) / 100) * percentValue / 100; var attackMoneyAfterDefend = (at.leftValue(car.ability) * (100 - at.GetDefensiveValue(victim.getCar().ability.driver, victim.improvementRecord.defenceValue > 0)) / 100) * percentValue / 100; attackMoneyBeforeDefend = Math.Max(1, attackMoneyBeforeDefend); attackMoneyAfterDefend = Math.Max(1, attackMoneyAfterDefend); long attackMoney; if (attackMoneyBeforeDefend == attackMoneyAfterDefend) { attackMoney = attackMoneyBeforeDefend; } else { attackMoney = attackMoneyAfterDefend; victim.improvementRecord.reduceDefend(victim, attackMoneyBeforeDefend, ref notifyMsg); } attackMoney = at.ImproveAttack(player, attackMoney, ref notifyMsg); reduce = attackMoney; if (reduce > m) { reduce = m; } reduce = Math.Max(1, reduce); at.setCost(reduce, player, car, ref notifyMsg); //this.WebNotify(victim, $"【{player.PlayerName}】对你进行了{at.GetSkillName()},损失{(reduce / 100.00).ToString("f2")}金币 "); this.WebNotify(player, $"你对【{victim.PlayerName}】进行了{at.GetSkillName()},获得{(reduce / 100.00).ToString("f2")}金币。其还有{(victim.Money / 100.00).ToString("f2")}金币。"); this.WebNotify(victim, $"【{player.PlayerName}】对你进行了{at.GetSkillName()},损失{(reduce / 100.00).ToString("f2")}金币 "); reduceSum += reduce; }
internal long DealWithReduceWhenSimulationWithoutDefendMagic(interfaceOfHM.AttackT at, RoleInGame player, Car car, RoleInGame victim, long percentValue) { var attackMoneyBeforeDefend = (at.leftValue(car.ability) * (100 - at.GetDefensiveValue(victim.getCar().ability.driver)) / 100) * percentValue / 100; return(attackMoneyBeforeDefend); }
internal void setDebt(commandWithTime.debtOwner dOwner, interfaceOfHM.AttackT at) { List <string> notifyMsg = new List <string>(); // bool needUpdatePlayers = false; lock (that.PlayerLock) { var player = that._Players[dOwner.key]; var car = that._Players[dOwner.key].getCar(); // car.targetFpIndex = this._Players[dor.key].StartFPIndex; ; if (at.CheckCarState(car)) { if (car.targetFpIndex == -1) { throw new Exception("居然来了一个没有目标的车!!!"); } else { /* * 当到达地点时,有可能攻击对象不存在。 * 也有可能攻击对象已破产。 * 还有正常情况。 * 这三种情况都要考虑到。 */ //attackTool at = new attackTool(); // var attackMoney = car.ability.Business; if (that._Players.ContainsKey(dOwner.victim)) { var victim = that._Players[dOwner.victim]; if (!victim.Bust) { var percentValue = getAttackPercentValue(player, victim); percentValue = at.DealWithPercentValue(percentValue, player, victim, this.that); //if(victim.Money*100/ car.ability.Business) long reduceSum = 0; var m = victim.Money - reduceSum; long reduce; if (m > 0) { this.DealWithReduceWhenAttack(at, player, car, victim, percentValue, ref notifyMsg, out reduce, m, ref reduceSum); } else { reduceSum = 0; reduce = 0; } if (at.isMagic) { that.magicE.AmbushSelf(victim, at, ref notifyMsg, ref reduceSum); at.MagicAnimateShow(player, victim, ref notifyMsg); } if (reduceSum > 0) { victim.MoneySet(victim.Money - reduceSum, ref notifyMsg); } if (reduce > 0) { this.WebNotify(player, $"你对【{victim.PlayerName}】进行了{at.GetSkillName()},获得{(reduce / 100.00).ToString("f2")}金币。其还有{(victim.Money / 100.00).ToString("f2")}金币。"); } if (victim.Money == 0) { victim.SetBust(true, ref notifyMsg); } if (victim.playerType == RoleInGame.PlayerType.NPC) { ((NPC)victim).BeingAttackedF(dOwner.key, ref notifyMsg); } } else { //这种情况也有可能存在。 } } else { //这种情况有可能存在. } /* * 无论什么情况,直接返回。 */ // if (car.ability.leftBusiness <= 0 && car.ability.leftVolume <= 0) { car.setState(player, ref notifyMsg, CarState.returning); that.retutnE.SetReturnT(0, new commandWithTime.returnning() { c = "returnning", key = dOwner.key, // car = dOwner.car, //returnPath = dOwner.returnPath,//returnPath_Record, target = dOwner.target, changeType = dOwner.changeType, returningOjb = dOwner.returningOjb }); } //else //{ // car.setState(player, ref notifyMsg, CarState.waitOnRoad); //} } } else { throw new Exception("car.state == CarState.buying!或者 dor.changeType不是四种类型"); } } for (var i = 0; i < notifyMsg.Count; i += 2) { var url = notifyMsg[i]; var sendMsg = notifyMsg[i + 1]; Console.WriteLine($"url:{url}"); Startup.sendMsg(url, sendMsg); } // Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}执行setReturn结束"); }