Beispiel #1
0
    public Boxer(JSONObject json) :
        base(
            JSONTemplates.ToVector2Int(json.GetField("age")), json.GetField("firstname").str, json.GetField("lastname").str,
            townId: (int)json.GetField("townindex").i, wt: json.GetField("weight").f
            )
    {
        boxerClass = global::BoxerClass.getTypeFromJson(json.GetField("weightclass"));

        accuracy  = (int)json.GetField("accuracy").i;
        endurance = (int)json.GetField("endurance").i;
        health    = (int)json.GetField("health").i;
        speed     = (int)json.GetField("speed").i;
        strength  = (int)json.GetField("strength").i;

        accuracyGrowth  = (int)json.GetField("accuracygrowth").i;
        enduranceGrowth = (int)json.GetField("endurancegrowth").i;
        healthGrowth    = (int)json.GetField("healthgrowth").i;
        speedGrowth     = (int)json.GetField("speedgrowth").i;
        strengthGrowth  = (int)json.GetField("strengthgrowth").i;

        record = new Record(json.GetField("record"));

        retired = json.GetField("retired").b;

        concussions = (int)json.GetField("concussions").i;
        fatigue     = (int)json.GetField("fatigue").i;
        maturity    = (int)json.GetField("maturity").i;
        stress      = (int)json.GetField("stress").i;

        equipedArms    = (int)json.GetField("arms").i;
        equipedLegs    = (int)json.GetField("legs").i;
        equipedImplant = (int)json.GetField("implant").i;
    }
Beispiel #2
0
    public Manager(
        string fName, string lName, int townId, float wt, BoxerClass.Type pref
        ) : base(new Vector2Int(1, 1), fName, lName, townId, wt)
    {
        preference = pref;

        record = new Record(40.0f);

        finance = new FinanceProtocol(5000);

        atSea        = false;
        atTournament = false;

        archivedBoxerELO   = new List <float>();
        archivedManagerELO = new List <float>();

        previousOpponents = new List <int>();

        tournamentCount    = 0;
        tournamentPriority = 0;

        consumables = new List <Consumable>();
        arms        = new List <Arm>();
        legs        = new List <Legs>();
        implants    = new List <Implant>();
    }
Beispiel #3
0
    public Boxer(
        Vector2Int age, string fName, string lName, int townId, float wt, BoxerClass.Type bClass,
        int acc, int accG, int end, int endG, int hlt, int hltG, int spd, int spdG, int str, int strG
        ) : base(age, fName, lName, townId, wt)
    {
        boxerClass = bClass;

        accuracy  = acc;
        endurance = end;
        health    = hlt;
        speed     = spd;
        strength  = str;

        accuracyGrowth  = accG;
        enduranceGrowth = endG;
        healthGrowth    = hltG;
        speedGrowth     = spdG;
        strengthGrowth  = strG;

        retired = false;

        record = new Record(120.0f);
        record.setELO(800.0f);

        concussions = 0;
        fatigue     = 0;
        maturity    = 0;
        stress      = 0;

        equipedArms    = -1;
        equipedLegs    = -1;
        equipedImplant = -1;
    }
Beispiel #4
0
    public void upgradeFacilities(ref DataPool worldData, float elo, BoxerClass.Type preference)
    {
        int pointsToGive = EvaluationProtocol.getFacilityPointsFromElo(elo);

        List <ManagerProtocol.FacilityShortcut> upgrades = new List <ManagerProtocol.FacilityShortcut> (new ManagerProtocol.FacilityShortcut[] {
            ManagerProtocol.FacilityShortcut.DoubleEndBag, ManagerProtocol.FacilityShortcut.PunchGlove, ManagerProtocol.FacilityShortcut.Laps,
            ManagerProtocol.FacilityShortcut.Sprints, ManagerProtocol.FacilityShortcut.PunchingBag
        });

        List <EvaluationProtocol.Stats> bestStats = BoxerClass.getBuild(preference);

        foreach (EvaluationProtocol.Stats stat in bestStats)
        {
            if (stat.Equals(EvaluationProtocol.Stats.AccuracyGrowth))
            {
                upgrades.Add(ManagerProtocol.FacilityShortcut.DoubleEndBag);
            }
            else if (stat.Equals(EvaluationProtocol.Stats.EnduranceGrowth))
            {
                upgrades.Add(ManagerProtocol.FacilityShortcut.PunchGlove);
            }
            else if (stat.Equals(EvaluationProtocol.Stats.HealthGrowth))
            {
                upgrades.Add(ManagerProtocol.FacilityShortcut.Laps);
            }
            else if (stat.Equals(EvaluationProtocol.Stats.SpeedGrowth))
            {
                upgrades.Add(ManagerProtocol.FacilityShortcut.Sprints);
            }
            else if (stat.Equals(EvaluationProtocol.Stats.StrengthGrowth))
            {
                upgrades.Add(ManagerProtocol.FacilityShortcut.PunchingBag);
            }
        }

        for (int i = 0; i < pointsToGive; i++)
        {
            if (upgrades.Count > 0)
            {
                ManagerProtocol.FacilityShortcut upgrade = upgrades [generateRandomInt(0, upgrades.Count - 1)];

                homeBaseFacilities [upgrade].upgradeFacility(ref worldData);

                if (homeBaseFacilities [upgrade].Level == 5)
                {
                    upgrades.Remove(upgrade);

                    if (upgrades.IndexOf(upgrade) >= 0)
                    {
                        upgrades.Remove(upgrade);
                    }
                }
            }
        }
    }
    public static List <int> getBoxersOfClass(ref DataPool worldData, BoxerClass.Type type)
    {
        List <int> boxerIndexes = new List <int>();

        for (int i = 0; i < worldData.Boxers.Count; i++)
        {
            if (worldData.Boxers[i].BoxerClass.Equals(type))
            {
                boxerIndexes.Add(i);
            }
        }

        return(boxerIndexes);
    }
Beispiel #6
0
    public static float evaluateBoxer(Boxer boxer, BoxerClass.Type type)
    {
        Dictionary <Stats, int> bestStats = identifyBestStats(boxer);

        float average = (float)(bestStats.Values.Sum() / 3.0f);

        int lower  = Mathf.RoundToInt((average - (average % 5.0f)) / 5.0f);
        int higher = Mathf.RoundToInt((average - (average % 5.0f)) / 5.0f) + 1;

        lower  = lower < 0 ? 0 : lower;
        higher = higher < 0 ? 0 : higher;

        float statValueLower  = statValueCurve [lower];
        float statValueHigher = statValueCurve [higher];

        float distance = (average % 5.0f) / 5.0f;

        float preferenceBooster = (boxer.BoxerClass == type) ? 0.1f : 0.0f;
        float overallBooster    = boxer.getOverall() / 990.0f;

        return(((statValueLower * distance) + (statValueHigher * (1.0f - distance))) + (preferenceBooster + overallBooster));
    }
Beispiel #7
0
    public Manager(JSONObject json)
        : base(JSONTemplates.ToVector2Int(json.GetField("age")), json.GetField("firstname").str, json.GetField("lastname").str,
               (int)json.GetField("townindex").i, (int)json.GetField("weight").i)
    {
        preference = (BoxerClass.Type)Enum.Parse(typeof(BoxerClass.Type), json.GetField("preference").str);

        boxerIndex = (int)json.GetField("boxerindex").i;

        record = new Record(json.GetField("record"));

        atSea        = json.GetField("atsea").b;
        atTournament = json.GetField("attournament").b;

        homebase = new Homebase(json.GetField("homebase"));
        ship     = new Ship(json.GetField("ship"));
        finance  = new FinanceProtocol(json.GetField("finance"));

        currentBoxerELO   = json.GetField("boxerelo").f;
        currentManagerELO = json.GetField("managerelo").f;

        tournamentCount    = (int)json.GetField("tournamentsattended").i;
        tournamentPriority = (int)json.GetField("priority").i;
        currentRanking     = (TournamentProtocol.Level)Enum.Parse(typeof(TournamentProtocol.Level), json.GetField("rank").str);

        trainingRegime = new List <ManagerProtocol.FacilityShortcut>();
        foreach (JSONObject r in json.GetField("trainingregime").list)
        {
            trainingRegime.Add((ManagerProtocol.FacilityShortcut)Enum.Parse(typeof(ManagerProtocol.FacilityShortcut), r.str));
        }

        archivedBoxerELO = new List <float>();
        foreach (JSONObject r in json.GetField("archivedboxerelo").list)
        {
            archivedBoxerELO.Add(r.f);
        }

        archivedManagerELO = new List <float>();
        foreach (JSONObject r in json.GetField("archivedmanagerelo").list)
        {
            archivedManagerELO.Add(r.f);
        }

        previousOpponents = new List <int>();
        foreach (JSONObject r in json.GetField("previousopponents").list)
        {
            previousOpponents.Add((int)r.i);
        }

        consumables = new List <Consumable>();
        foreach (JSONObject r in json.GetField("consumables").list)
        {
            consumables.Add(new Consumable(r));
        }

        arms = new List <Arm>();
        foreach (JSONObject r in json.GetField("arms").list)
        {
            arms.Add(new Arm(r));
        }

        legs = new List <Legs>();
        foreach (JSONObject r in json.GetField("legs").list)
        {
            legs.Add(new Legs(r));
        }

        implants = new List <Implant>();
        foreach (JSONObject r in json.GetField("implants").list)
        {
            implants.Add(new Implant(r));
        }
    }
    public static Boxer createBoxerBasedOnFame(string firstName, string lastName, int townIndex, float elo, WeightClass.WClass wClass)
    {
        int pointsToGive = EvaluationProtocol.getBoxerPointsFromFame(elo);

        int badStatRates = Mathf.RoundToInt((pointsToGive / 3) / 2);

        badStatRates = badStatRates < 1 ? 1 : badStatRates;

        List <BoxerClass.Type> possibleClasses = BoxerClass.getClassesBasedOnWeight(wClass);

        List <EvaluationProtocol.Stats> stats = new List <EvaluationProtocol.Stats>(new EvaluationProtocol.Stats[] {
            EvaluationProtocol.Stats.AccuracyGrowth, EvaluationProtocol.Stats.EnduranceGrowth, EvaluationProtocol.Stats.HealthGrowth,
            EvaluationProtocol.Stats.SpeedGrowth, EvaluationProtocol.Stats.StrengthGrowth
        });

        Dictionary <EvaluationProtocol.Stats, int> growthRates = new Dictionary <EvaluationProtocol.Stats, int>();
        Dictionary <EvaluationProtocol.Stats, int> statValues  = new Dictionary <EvaluationProtocol.Stats, int>();

        foreach (EvaluationProtocol.Stats stat in stats)
        {
            growthRates.Add(stat, badStatRates);
        }

        BoxerClass.Type bClass = possibleClasses[generateRandomInt(0, possibleClasses.Count - 1)];

        List <EvaluationProtocol.Stats> bestStats = BoxerClass.getBuild(bClass);

        for (int i = 0; i < 3; i++)
        {
            int baseStat = Mathf.RoundToInt(pointsToGive / (3 - i));

            if (pointsToGive > 1)
            {
                baseStat = generateRandomInt(baseStat - 1, baseStat + 1);
                baseStat = baseStat < 1 ? 1 : baseStat;
                baseStat = baseStat > 10 ? 10 : baseStat;
                baseStat = (pointsToGive - baseStat) < 2 ? baseStat - 1 : baseStat;
                baseStat = baseStat < 1 ? 1 : baseStat;
            }
            else
            {
                baseStat = pointsToGive;
            }


            EvaluationProtocol.Stats stat = bestStats[generateRandomInt(0, bestStats.Count - 1)];

            growthRates[stat] = baseStat;
            bestStats.RemoveAt(bestStats.IndexOf(stat));
            pointsToGive -= baseStat;
        }

        int acc = EvaluationProtocol.getStatValueFromGrowthRate(growthRates[EvaluationProtocol.Stats.AccuracyGrowth]);
        int end = EvaluationProtocol.getStatValueFromGrowthRate(growthRates[EvaluationProtocol.Stats.EnduranceGrowth]);
        int hlt = EvaluationProtocol.getStatValueFromGrowthRate(growthRates[EvaluationProtocol.Stats.HealthGrowth]);
        int spd = EvaluationProtocol.getStatValueFromGrowthRate(growthRates[EvaluationProtocol.Stats.SpeedGrowth]);
        int str = EvaluationProtocol.getStatValueFromGrowthRate(growthRates[EvaluationProtocol.Stats.StrengthGrowth]);

        statValues.Add(EvaluationProtocol.Stats.Accuracy, generateRandomInt(acc - 4, acc + 4));
        statValues.Add(EvaluationProtocol.Stats.Endurance, generateRandomInt(end - 4, end + 4));
        statValues.Add(EvaluationProtocol.Stats.Health, generateRandomInt(hlt - 4, hlt + 4));
        statValues.Add(EvaluationProtocol.Stats.Speed, generateRandomInt(spd - 4, spd + 4));
        statValues.Add(EvaluationProtocol.Stats.Strength, generateRandomInt(str - 4, str + 4));

        return(new Boxer(
                   new Vector2Int(0, 1), firstName, lastName, townIndex, generateWeightFromClass(wClass), bClass,
                   statValues[EvaluationProtocol.Stats.Accuracy], growthRates[EvaluationProtocol.Stats.AccuracyGrowth],
                   statValues[EvaluationProtocol.Stats.Endurance], growthRates[EvaluationProtocol.Stats.EnduranceGrowth],
                   statValues[EvaluationProtocol.Stats.Health], growthRates[EvaluationProtocol.Stats.HealthGrowth],
                   statValues[EvaluationProtocol.Stats.Speed], growthRates[EvaluationProtocol.Stats.SpeedGrowth],
                   statValues[EvaluationProtocol.Stats.Strength], growthRates[EvaluationProtocol.Stats.StrengthGrowth]));
    }