124 lines
6.4 KiB
Plaintext
124 lines
6.4 KiB
Plaintext
using System;
|
|
foreach(var c in new[]{(10f,0.25f,10,0.5f,0.5f,0.2f,0.1f,122),(0f,0.25f,10,0.5f,0.5f,0.2f,0.1f,0),(10f,0f,1,1f,0f,0f,0f,10),(1f,0f,1,0.5f,0f,0f,0f,0)}){
|
|
var old=new OldFormula();var next=new NewFormula();
|
|
foreach(var x in new FormulaBase[]{old,next}){x._tables.TbDrop[0].DropList.DropCountList[1]=c.Item1;x.pointBonus=c.Item2;x.Magnification=c.Item3;x.fishingData.random=c.Item4;x.fishingData.WeightIncEvent=c.Item5;x.playerData.benefitsCashMag=c.Item6;GContext.container.Buff.Gold=c.Item7;}
|
|
int a=old.Run(),b=next.Run();if(a!=c.Item8||b!=a)throw new Exception($"Formula {a}/{b} expected {c.Item8}");Console.WriteLine($"PASS original/current cash={b}");
|
|
}
|
|
public class FormulaBase {public Tables _tables=new();public Fishing fishingData=new();public Player playerData=new();public float pointBonus,extraPointEvent;public int Magnification;protected float _fishScore;protected Text text_gold_num=new(),text_num_buff=new();}
|
|
public class Tables {public Drop[] TbDrop={new()};}public class Drop{public DropPackageList DropList=new();}public class DropPackageList {public float[] DropCountList={20,10};}
|
|
public class Fishing{public Fish curFishData=new(),fishItem=new();public float random,fishWeight,WeightIncEvent;public int MapId;public bool IsNewItemFish()=>false;}
|
|
public class Fish{public int DropID,ID,Quality=2;}public class Player{public float benefitsCashMag,benefitsEventFishCashMag;}
|
|
public class CollectingData{public float ExtraCashDrop()=>0;}public class BuffDataCenter{public float Gold;public float GetExtraGoldBuffValue(int m,int q)=>Gold;}
|
|
public class FishingChallengeManager{public void AddScoreByQuality(int a,float b,int c){}}
|
|
public class Container{public BuffDataCenter Buff=new();public T Resolve<T>() where T:new()=>typeof(T)==typeof(BuffDataCenter)?(T)(object)Buff:new T();}
|
|
public static class GContext{public static Container container=new();}public class Text{public Color color;}public struct Color{public static Color black,white;}
|
|
public static class Mathf{public static int RoundToInt(float x)=>(int)MathF.Round(x,MidpointRounding.ToEven);}
|
|
public class OldFormula : FormulaBase { public int Run(){DropPackageList dropPackageList = _tables.TbDrop[fishingData.curFishData.DropID].DropList;
|
|
float proficiency = dropPackageList.DropCountList[0] * fishingData.random;
|
|
var proficiencyExtra = SetProficiency(proficiency, extraPointEvent, fishingData.curFishData.ID);//额外的Buff加成
|
|
var endWeight = fishingData.fishWeight;
|
|
float extraCashDrop = GContext.container.Resolve<CollectingData>().ExtraCashDrop();
|
|
//Data
|
|
//金币各种加成
|
|
float gold = (dropPackageList.DropCountList[1] + extraCashDrop)
|
|
* (1 + pointBonus)
|
|
* Magnification
|
|
* fishingData.random;
|
|
//杆加成
|
|
//解锁地图Buff加成
|
|
float glodBuff = GContext.container.Resolve<BuffDataCenter>().GetExtraGoldBuffValue(fishingData.MapId, fishingData.fishItem.Quality);
|
|
|
|
if (glodBuff > 0.001f)
|
|
{
|
|
text_gold_num.color = Color.black;
|
|
text_num_buff.color = Color.white;
|
|
}
|
|
int Quality = fishingData.curFishData.Quality;
|
|
if (Quality > 6)
|
|
{
|
|
Quality = 6;
|
|
}
|
|
|
|
//权益全局加成
|
|
var ExtraPoint = playerData.benefitsCashMag + glodBuff;
|
|
int cash = Mathf.RoundToInt(gold * proficiencyExtra * (1 + ExtraPoint));
|
|
|
|
return cash;}float SetProficiency(float proficiency, float proficiencyExtra, int fishId)
|
|
{
|
|
int Quality = fishingData.curFishData.Quality;
|
|
if (Quality > 6)
|
|
{
|
|
Quality = 6;
|
|
}
|
|
if (!fishingData.IsNewItemFish())
|
|
{
|
|
proficiencyExtra = (1 + fishingData.WeightIncEvent) * (1 + proficiencyExtra);
|
|
}
|
|
else
|
|
{
|
|
proficiencyExtra = (1 + proficiencyExtra) * (1 + playerData.benefitsEventFishCashMag);
|
|
}
|
|
|
|
proficiency *= proficiencyExtra;
|
|
proficiency = Mathf.RoundToInt(proficiency);
|
|
|
|
GContext.container.Resolve<FishingChallengeManager>().AddScoreByQuality(Quality, proficiency, fishId);
|
|
|
|
_fishScore = proficiency;
|
|
return proficiencyExtra;
|
|
}}
|
|
public class NewFormula : FormulaBase { public int Run(){DropPackageList dropPackageList = _tables.TbDrop[fishingData.curFishData.DropID].DropList;
|
|
float proficiency = dropPackageList.DropCountList[0] * fishingData.random;
|
|
var proficiencyExtra = SetProficiency(proficiency, extraPointEvent, fishingData.curFishData.ID);//额外的Buff加成
|
|
var endWeight = fishingData.fishWeight;
|
|
float extraCashDrop = GContext.container.Resolve<CollectingData>().ExtraCashDrop();
|
|
//Data
|
|
//金币各种加成
|
|
float gold = (dropPackageList.DropCountList[1] + extraCashDrop)
|
|
* (1 + pointBonus)
|
|
* Magnification
|
|
* fishingData.random;
|
|
//杆加成
|
|
//解锁地图Buff加成
|
|
float glodBuff = GContext.container.Resolve<BuffDataCenter>().GetExtraGoldBuffValue(fishingData.MapId, fishingData.fishItem.Quality);
|
|
|
|
if (glodBuff > 0.001f)
|
|
{
|
|
text_gold_num.color = Color.black;
|
|
text_num_buff.color = Color.white;
|
|
}
|
|
int Quality = fishingData.curFishData.Quality;
|
|
if (Quality > 6)
|
|
{
|
|
Quality = 6;
|
|
}
|
|
|
|
//权益全局加成
|
|
var ExtraPoint = playerData.benefitsCashMag + glodBuff;
|
|
int cash = Mathf.RoundToInt(gold * proficiencyExtra * (1 + ExtraPoint));
|
|
|
|
return cash;}float SetProficiency(float proficiency, float proficiencyExtra, int fishId)
|
|
{
|
|
int Quality = fishingData.curFishData.Quality;
|
|
if (Quality > 6)
|
|
{
|
|
Quality = 6;
|
|
}
|
|
if (!fishingData.IsNewItemFish())
|
|
{
|
|
proficiencyExtra = (1 + fishingData.WeightIncEvent) * (1 + proficiencyExtra);
|
|
}
|
|
else
|
|
{
|
|
proficiencyExtra = (1 + proficiencyExtra) * (1 + playerData.benefitsEventFishCashMag);
|
|
}
|
|
|
|
proficiency *= proficiencyExtra;
|
|
proficiency = Mathf.RoundToInt(proficiency);
|
|
|
|
GContext.container.Resolve<FishingChallengeManager>().AddScoreByQuality(Quality, proficiency, fishId);
|
|
|
|
_fishScore = proficiency;
|
|
return proficiencyExtra;
|
|
}}
|