public HitHandler(IFishStage _Stage, HitRequest request) { this._Stage = _Stage; _Request = request; _Enable = true; _TimeCounter = new TimeCounter(); }
public static FarmDataRoot.BlockNode.BLOCK_NAME GetBlock(HitRequest request, int max_bet) { var bet = request.WeaponData.GetTotalBet(); if(bet >= ((750 * max_bet) / 1000)) { return FarmDataRoot.BlockNode.BLOCK_NAME.BLOCK_5; } if(bet >= ((500 * max_bet) / 1000)) { return FarmDataRoot.BlockNode.BLOCK_NAME.BLOCK_4; } if(bet >= ((250 * max_bet) / 1000)) { return FarmDataRoot.BlockNode.BLOCK_NAME.BLOCK_3; } if(bet >= ((100 * max_bet) / 1000)) { return FarmDataRoot.BlockNode.BLOCK_NAME.BLOCK_2; } return FarmDataRoot.BlockNode.BLOCK_NAME.BLOCK_1; }
public void TestHitFormulaDeath1() { var random = Substitute.For<IRandom>(); var formula = new HitTest(random); random.NextLong(Arg.Any<long>(), Arg.Any<long>()).Returns(0xffffffe); var fishs = new List<RequsetFishData> { new RequsetFishData { FishId = 1, FishOdds = 1 } }; var weapon = new RequestWeaponData { TotalHits = 1, WeaponBet = 1, WeaponOdds = 1, BulletId = 1 }; var request = new HitRequest(fishs.ToArray(), weapon, true); var hitResponses = formula.TotalRequest(request); foreach(var respones in hitResponses) { Assert.AreEqual(1, respones.WepId); Assert.AreEqual(1, respones.FishId); Assert.AreEqual(FISH_DETERMINATION.DEATH, respones.DieResult); } }
void IFishStage.Hit(HitRequest request) { var responses = _Formula.TotalRequest(request); _OnTotalHitResponseEvent.Invoke(responses); _MakeLog(request, responses); }
private void _HitRequest(int total_hits) { var hitFishs = _SimulateRequsetFishData(total_hits); var weaponData = _SimulateRequestWeaponData(total_hits); var hitRequest = new HitRequest(hitFishs.ToArray(), weaponData, true); var hitHandler = new HitHandler(_Stage, hitRequest); _HitHandlers.Add(hitHandler); }
public FloatingOddsActuator(HitRequest hit_request) { _HitRequest = hit_request; _OddsRules = new List<IFloatingCalculator> { new BigOctopus(), new King(), new WhaleColor(), new WhaleSliver() }; }
private void _MakeLog(HitRequest request, HitResponse[] responses) { var format = "PlayerVisitor:{0}\tStage:{1}\nRequest:{2}\nResponse:{3}"; var log = string.Format( format, _AccountId, _FishStage, request.ShowMembers(" "), responses.ShowMembers(" ")); Singleton<Log>.Instance.WriteInfo(log); }
public static void Select(HitRequest hit_request) { if(!hit_request.IsFirstTrigger) { return; } var giftFish = hit_request.FishDatas.FirstOrDefault(x => x.FishOdds <= _GiftOdds); if(giftFish != null) { giftFish.IsGift = true; } }
void IFishStage.Hit(HitRequest request) { _OnTotalHitResponseEvent( request.FishDatas.Select( requset_fish_data => new HitResponse { DieResult = Random.Instance.NextInt(1, 4) == 1 ? FISH_DETERMINATION.DEATH : FISH_DETERMINATION.SURVIVAL, FishId = requset_fish_data.FishId, WepId = request.WeaponData.BulletId, FeedbackWeapons = new[] { WEAPON_TYPE.INVALID } }).ToArray()); }
internal void Conver(int wepbet, int totalhits, int fishodds) { var weaponData = new RequestWeaponData { WeaponBet = wepbet, TotalHits = totalhits }; var fishDatas = new List<RequsetFishData> { new RequsetFishData() }; var hitRequest = new HitRequest(fishDatas.ToArray(), weaponData, true); _Gpi.Hit(hitRequest); }
void IFishStage.Hit(HitRequest request) { _SerializeRule(request); if(!_CheckDataLegality(request)) { return; } var hitResponses = new ZsHitChecker(_FishFarmData, _FormulaPlayerRecord).TotalRequest(request); _FormulaFarmRecorder.Save(_FishFarmData); _FormulaPlayerRecorder.Save(_FormulaPlayerRecord); _OnTotalHitResponseEvent?.Invoke(hitResponses); _MakeLog(request, hitResponses); }
public SpecialWeaponSelector(HitRequest request) { _HitRequest = request; _Weapons = new List<Data> { new Data { WeaponType = WEAPON_TYPE.BIG_OCTOPUS_BOMB, WeaponRule = new BigOctopusBomb() }, new Data { WeaponType = WEAPON_TYPE.THUNDER_BOMB, WeaponRule = new ThunderBomb() } }; }
public override HitResponse[] TotalRequest(HitRequest request) { var handler = new HitPipelineHandler(_DataVisitor, request); return handler.SetFocusBlock() .SetFishDieRateFromHitOrder() .OddsCalculate() .FloatingOddsActuate() .SpecialWeaponSelect() .LotteryTreasure() .AccumulationBuffer() .ApproachBaseOdds() .AdjustmentAverage() .AdjustmentGameLevel() .AdjustmentPlayerPhase() .DieRateCalculate() .Record() .Log() .Process() .ToArray(); }
private void _MakeRequestLog(HitRequest request) { foreach(var data in request.FishDatas) { var log = LogManager.GetLogger("Request"); log.Info() .Message("Request Data") .Property("FarmId", _FishFarmData.FarmId) .Property("PlayerId", _AccountId) .Property("BulletId", request.WeaponData.BulletId) .Property("WeaponType", request.WeaponData.WeaponType) .Property("Bet", request.WeaponData.WeaponBet) .Property("Odds", request.WeaponData.WeaponOdds) .Property("Hits", request.WeaponData.TotalHits) .Property("FishId", data.FishId) .Property("FishType", data.FishType) .Property("FishStatus", data.FishStatus) .Property("FishOdds", data.FishOdds) .Write(); } }
public ResponseMaker(DataVisitor visitor, HitRequest request) { _Visitor = visitor; _Request = request; _HitResponses = new List<HitResponse>(); }
public void When得到檢查結果() { _HitRequest = new HitRequest(_FishDatas, _WeaponData, true); _HitResponses = new ZsHitChecker(_FarmData, new FormulaPlayerRecord()).TotalRequest(_HitRequest); }
public DieRateCalculator(DataVisitor visitor, HitRequest request) { _Visitor = visitor; _Request = request; }
Value<int> IPlayer.Hit(int bullet_id, int[] fishids) { var hasBullet = _PopBullet(bullet_id); if(hasBullet == false) { return 0; } var logFishs = string.Empty; var count = 0; foreach(var fishid in fishids) { if(_PopFish(fishid) == false) { continue; } if(_Requests.ContainsKey(fishid)) { continue; } count++; var fishs = new List<RequsetFishData> { new RequsetFishData { FishId = fishid, FishOdds = 1, FishStatus = FISH_STATUS.NORMAL, FishType = FISH_TYPE.TROPICAL_FISH } }; var weapon = new RequestWeaponData { TotalHits = fishids.Length, WeaponBet = _WeaponBet, BulletId = bullet_id, WeaponOdds = 1, WeaponType = _WeaponType }; var request = new HitRequest(fishs.ToArray(), weapon, true); _Requests.Add(fishid, request); _FishStage.Hit(request); logFishs += fishid + ","; } if(count == 0) { _PushBullet(bullet_id); } Singleton<Log>.Instance.WriteInfo( string.Format( "all WEAPON_TYPE:{0} , targets:{1} , count:{2}", bullet_id, string.Join(",", (from id in fishids select id.ToString()).ToArray()), fishids.Length)); Singleton<Log>.Instance.WriteInfo( string.Format("requested WEAPON_TYPE:{0} , targets:{1} , count:{2}", bullet_id, logFishs, count)); Singleton<Log>.Instance.WriteInfo( string.Format( "request fishs:{0} count:{1} ", string.Join(",", (from id in _Requests.Keys select id.ToString()).ToArray()), _Requests.Count)); return count; }
public AdjustmentAverage(DataVisitor fish_visitor, HitRequest hit_request) { _DataVisitor = fish_visitor; _HitRequest = hit_request; }
/// <summary> /// 因為Serialize 無法實現空array,因應下面邏輯判斷, /// 如果是null 就產生空array /// </summary> /// <param name="request"></param> private void _SerializeRule(HitRequest request) { foreach(var fishData in request.FishDatas.Where(fish_data => fish_data.GraveGoods == null)) { fishData.GraveGoods = new RequsetFishData[0]; } }
public HitPipelineHandler(DataVisitor data_visitor, HitRequest request) { _DataVisitor = data_visitor; _Request = request; _PipelineElements = new List<IPipelineElement>(); }
public SpecialWeaponRateCal(DataVisitor visitor, HitRequest request) { _Visitor = visitor; _Request = request; }
public Record(DataVisitor visitor, HitRequest request) { _Visitor = visitor; _Request = request; }
public override HitResponse[] TotalRequest(HitRequest request) { throw new NotImplementedException(); }
public Odds(DataVisitor visitor, HitRequest hit_request) { _Visitor = visitor; _HitRequest = hit_request; }
public void TestHitFormulaDeath2() { var random = Substitute.For<IRandom>(); var formula = new HitTest(random); random.NextLong(Arg.Any<long>(), Arg.Any<long>()).Returns(0x0fffffff / 26); // 9d89d8 var fishs = new List<RequsetFishData> { new RequsetFishData { FishId = 1, FishOdds = 25 } }; var weapon = new RequestWeaponData { TotalHits = 1, WeaponBet = 1, WeaponOdds = 1, BulletId = 1, WeaponType =WEAPON_TYPE.INVALID }; var hitRequest = new HitRequest(fishs.ToArray(), weapon, true); var hitResponses = formula.TotalRequest(hitRequest); // a3d70a foreach(var response in hitResponses) { Assert.AreEqual(1, response.WepId); Assert.AreEqual(1, response.FishId); Assert.AreEqual(FISH_DETERMINATION.DEATH, response.DieResult); } }
public void TestHitFormulaSurvival2() { var random = Substitute.For<IRandom>(); var formula = new HitTest(random); random.NextLong(Arg.Any<long>(), Arg.Any<long>()).Returns(0x0fffffff / 25); var fishs = new List<RequsetFishData> { new RequsetFishData { FishId = 1, FishOdds = 25 } }; var weapon = new RequestWeaponData { TotalHits = 1, WeaponBet = 1, WeaponOdds = 1, BulletId = 1 }; var request = new HitRequest(fishs.ToArray(), weapon, true); var hitResponses = formula.TotalRequest(request); foreach(var response in hitResponses) { Assert.AreEqual(1, response.WepId); Assert.AreEqual(WEAPON_TYPE.INVALID, response.FeedbackWeapons[0]); Assert.AreEqual(1, response.FishId); Assert.AreEqual(FISH_DETERMINATION.SURVIVAL, response.DieResult); } }
public override HitResponse[] TotalRequest(HitRequest request) { var hitResponses = new List<HitResponse>(); foreach(var fishData in request.FishDatas) { const int MAX_WEPBET = 10000; const int MAX_WEPODDS = 10000; const short MAX_TOTALHITS = 1000; const short MAX_FISHODDS = 1000; const long gateOffset = 0x0fffffff; if(request.WeaponData.WeaponBet > MAX_WEPBET) { hitResponses.Add(_Miss(fishData, request.WeaponData)); continue; } if(request.WeaponData.WeaponOdds > MAX_WEPODDS) { hitResponses.Add(_Miss(fishData, request.WeaponData)); continue; } if(request.WeaponData.TotalHits == 0 || request.WeaponData.TotalHits > MAX_TOTALHITS) { hitResponses.Add(_Miss(fishData, request.WeaponData)); continue; } if(fishData.FishOdds == 0 || fishData.FishOdds > MAX_FISHODDS) { hitResponses.Add(_Miss(fishData, request.WeaponData)); } else { long gate = 1000; gate *= gateOffset; gate *= request.WeaponData.WeaponBet; gate /= request.WeaponData.TotalHits; gate /= fishData.FishOdds; gate /= 1000; if(gate > 0x0fffffff) { gate = 0x10000000; } var rValue = _Random.NextLong(0, long.MaxValue); var value = rValue % 0x10000000; if(value < gate) { hitResponses.Add(_Die(fishData, request.WeaponData)); } else { hitResponses.Add(_Miss(fishData, request.WeaponData)); } } } return hitResponses.ToArray(); }
public abstract HitResponse[] TotalRequest(HitRequest request);
private void _MakeLog(HitRequest request, IEnumerable<HitResponse> responses) { _MakeRequestLog(request); _MakeResponseLog(responses); }