internal void ServerDoSummon(int _tmpCardUid, int _pos) { Dictionary <int, int> handCards = isMineAction ? mHandCards : oHandCards; if (!mapDic.ContainsKey(_pos) || mapDic[_pos] != isMineAction || !handCards.ContainsKey(_tmpCardUid)) { Log.Write("ServerDoSummon 违规操作 uid:" + _tmpCardUid + " pos:" + _pos); return; } int cardID = handCards[_tmpCardUid]; IHeroSDS heroSDS = heroDataDic[cardID]; if (heroSDS.GetCost() > (isMineAction ? mMoney : oMoney)) { Log.Write("ServerDoSummon 违规操作 oMoney:" + oMoney); return; } handCards.Remove(_tmpCardUid); DoSummon(cardID, _pos); using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { bw.Write(PackageTag.S2C_DOACTION); bw.Write((int)ActionType.SUMMON); bw.Write(cardID); bw.Write(_pos); serverSendDataCallBack(true, ms); if (!isVsAi) { serverSendDataCallBack(false, ms); } else { if (!isMineAction) { BattleAi2.Action(this); } } } } }
internal void ServerDoSkip() { if (isSkip) { Log.Write("ServerStartBattle"); ServerStartBattle(); Log.Write("ServerEndBattle"); } else { using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { isSkip = true; isMineAction = !isMineAction; bw.Write(PackageTag.S2C_DOACTION); bw.Write((int)ActionType.NONE); serverSendDataCallBack(true, ms); if (!isVsAi) { serverSendDataCallBack(false, ms); } else { if (!isMineAction) { BattleAi2.Action(this); } } } } } }
private void ServerStartBattle() { using (MemoryStream mMs = new MemoryStream(), oMs = new MemoryStream()) { using (BinaryWriter mBw = new BinaryWriter(mMs), oBw = new BinaryWriter(oMs)) { mBw.Write(PackageTag.S2C_PLAYBATTLE); oBw.Write(PackageTag.S2C_PLAYBATTLE); DoAttack(mBw, oBw); HeroRecoverPower(); RecoverCards(mBw, oBw); RecoverMoney(); isSkip = false; //isMineAction = !isMineAction;//设置行动顺序 serverSendDataCallBack(true, mMs); if (!isVsAi) { serverSendDataCallBack(false, oMs); } else { if (!isMineAction) { BattleAi2.Action(this); } } } } }
public void ServerStart(int _mapID, List <int> _mCards, List <int> _oCards, bool _isVsAi) { Log.Write("Battle2 Start!"); random = new Random(); isVsAi = _isVsAi; heroUid = 1; mapData = mapDataDic[_mapID]; heroMapDic = new Dictionary <int, Hero2>(); mapDic = new Dictionary <int, bool>(); Dictionary <int, bool> .Enumerator enumerator = mapData.dic.GetEnumerator(); while (enumerator.MoveNext()) { mapDic.Add(enumerator.Current.Key, enumerator.Current.Value); } mScore = mapData.score1; oScore = mapData.score2; mMoney = oMoney = DEFAULT_MONEY; cardUid = 1; mCards = _mCards; oCards = _oCards; mHandCards = new Dictionary <int, int>(); oHandCards = new Dictionary <int, int>(); for (int i = 0; i < DEFAULT_HAND_CARD_NUM; i++) { int index = (int)(random.NextDouble() * mCards.Count); mHandCards.Add(GetCardUid(), mCards[index]); mCards.RemoveAt(index); index = (int)(random.NextDouble() * oCards.Count); oHandCards.Add(GetCardUid(), oCards[index]); oCards.RemoveAt(index); } isSkip = false; isMineAction = random.NextDouble() < 0.5; ServerRefreshData(true); if (!isVsAi) { ServerRefreshData(false); } else { if (!isMineAction) { BattleAi2.Action(this); } } }
internal void ServerDoMove(int _pos, int _direction) { if (!heroMapDic.ContainsKey(_pos)) { return; } Hero2 hero = heroMapDic[_pos]; if (hero.isMine != isMineAction) { Log.Write("ServerDoMove 违规操作1"); return; } if (hero.nowPower < 1 || hero.isSummon) { Log.Write("ServerDoMove 违规操作2"); return; } if (_direction < 0 || _direction > 6) { Log.Write("ServerDoMove 违规操作3"); return; } int targetPos = mapData.neighbourPosMap[_pos][_direction]; if (targetPos == -1) { Log.Write("ServerDoMove 违规操作4"); return; } if (heroMapDic.ContainsKey(targetPos)) { Log.Write("ServerDoMove 违规操作5"); return; } DoMove(_pos, _direction); using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { bw.Write(PackageTag.S2C_DOACTION); bw.Write((int)ActionType.MOVE); bw.Write(_pos); bw.Write(_direction); serverSendDataCallBack(true, ms); if (!isVsAi) { serverSendDataCallBack(false, ms); } else { if (!isMineAction) { BattleAi2.Action(this); } } } } }