コード例 #1
0
ファイル: ManagerProtocol.cs プロジェクト: jmacattack22/DadXO
    private static void disposeAndRenewBoxer(ref DataPool worldData, int managerIndex)
    {
        float        currentManagerELO = worldData.Managers[managerIndex].ManagerELO;
        List <Boxer> boxers            = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, worldData.Managers[managerIndex].TownIndex, currentManagerELO);

        int   bIndex = 0;
        float max    = 0.0f;

        for (int i = 0; i < boxers.Count; i++)
        {
            float boxerEval = EvaluationProtocol.evaluateBoxer(boxers[i], worldData.Managers[managerIndex].Preference);

            if (boxerEval > max)
            {
                max    = boxerEval;
                bIndex = i;
            }
        }

        worldData.Boxers.Add(boxers[bIndex]);

        worldData.Managers[managerIndex].recruitBoxer(worldData.Boxers.Count - 1);
        worldData.Managers[managerIndex].setRank(TournamentProtocol.Level.E);
        updateELO(ref worldData, managerIndex);
    }
コード例 #2
0
    private static List <int> recruit(DataPool worldData, TournamentProtocol.Level level, List <int> regionsWithinJurisdiction, bool highestRated)
    {
        List <int> potentialRecruits = new List <int>();

        foreach (int rIndex in regionsWithinJurisdiction)
        {
            foreach (int mIndex in worldData.Regions[rIndex].getRegionsManagerIndexes())
            {
                if (worldData.Managers[mIndex].Rank.Equals(level) && !worldData.Managers[mIndex].isBusy())
                {
                    potentialRecruits.Add(mIndex);
                }
            }
        }

        if (highestRated)
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => EvaluationProtocol.evaluateBoxer(worldData.Boxers[t])).ToList();
        }
        else
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => worldData.Managers[t].Priority).ToList();
        }

        return(potentialRecruits);
    }
コード例 #3
0
ファイル: UpgradableItem.cs プロジェクト: jmacattack22/DadXO
 public void setDistribution(List <JSONObject> stats)
 {
     foreach (JSONObject j in stats)
     {
         distribution.Add(EvaluationProtocol.getStatFromJson(j));
     }
 }
コード例 #4
0
    public void logBoxerResults()
    {
        List <Manager> managers = worldData.Managers.OrderByDescending(m => EvaluationProtocol.evaluateBoxer(worldData.Boxers[m.BoxerIndex])).ToList();

        foreach (Manager m in managers)
        {
            worldData.Boxers[m.BoxerIndex].logBoxerStats(m.Rank);
        }
    }
コード例 #5
0
ファイル: Homebase.cs プロジェクト: jmacattack22/DadXO
    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);
                    }
                }
            }
        }
    }
コード例 #6
0
ファイル: DataPool.cs プロジェクト: jmacattack22/DadXO
    private void balanceRank(TournamentProtocol.Level rank)
    {
        foreach (Region r in regions)
        {
            List <int> managerIndexes = r.getRegionsManagerIndexes().FindAll(index => managers[index].Rank.Equals(rank)).ToList();

            managerIndexes = managerIndexes.OrderByDescending(index => EvaluationProtocol.evaluateBoxer(boxers[managers[index].BoxerIndex])).ToList();

            if (managerIndexes.Count > 12)
            {
                managers[managerIndexes[0]].graduateRank();
            }
        }
    }
コード例 #7
0
    void Start()
    {
        worldData = new DataPool();

        WorldBuilderProtocol.createWorld(ref worldData, 220, 220);

        Manager manager = new Manager("Capn", "AT", 0, 155.0f, BoxerClass.Type.Bullseye);

        worldData.Managers.Add(manager);

        List <Boxer> boxers = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, manager.TownIndex, 0);

        int   bIndex = 0;
        float max    = 0.0f;

        for (int i = 0; i < boxers.Count; i++)
        {
            float boxerEval = EvaluationProtocol.evaluateBoxer(boxers [i], worldData.Managers [0].Preference);

            Debug.Log(boxerEval);
            boxers [i].logBoxerStats();

            if (boxerEval > max)
            {
                max    = boxerEval;
                bIndex = i;
            }
        }

        worldData.Boxers.Add(boxers [bIndex]);
        manager.recruitBoxer(worldData.Boxers.Count - 1);

        for (int i = 0; i < 5; i++)
        {
            Debug.Log("Year " + (i + 1));
            for (int j = 0; j < 48; j++)
            {
                ManagerProtocol.executeWeek(ref worldData, 0);
                worldData.Boxers [manager.BoxerIndex].logBoxerStats();
            }
        }
    }
コード例 #8
0
ファイル: TournamentTest.cs プロジェクト: jmacattack22/DadXO
    private List <int> recruit(TournamentProtocol.Level level, Vector2Int p1, bool highestRated)
    {
        List <int> potentialRecruits = new List <int>();

        int index = 0;

        foreach (Manager m in worldData.Managers)
        {
            Vector2Int p2 = worldData.Towns[worldData.Managers[index].TownIndex].Location;

            float distance = Mathf.Sqrt(Mathf.Pow((p2.x - p1.x), 2) + Mathf.Pow((p2.y - p1.y), 2));

            if (level.Equals(TournamentProtocol.Level.S))
            {
                if (m.Rank.Equals(level) && !m.isBusy())
                {
                    potentialRecruits.Add(index);
                }
            }
            else
            {
                if (distance < getDistanceFromLevel(level) && m.Rank.Equals(level) && !m.isBusy())
                {
                    potentialRecruits.Add(index);
                }
            }

            index++;
        }

        if (highestRated)
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => EvaluationProtocol.evaluateBoxer(worldData.Boxers[t])).ToList();
        }
        else
        {
            potentialRecruits = potentialRecruits.OrderByDescending(t => worldData.Managers[t].Priority).ToList();
        }

        return(potentialRecruits);
    }
コード例 #9
0
    private static void createManagerBasedOnTown(ref DataPool worldData, int townIndex, int regionIndex)
    {
        for (int j = 0; j < 2; j++)
        {
            List <BoxerClass.Type> typeList = BoxerClass.getTypeList();

            Manager manager = new Manager(
                worldData.generateFirstName(), worldData.generateLastName(), townIndex, generateRandomInt(145, 225), typeList[generateRandomInt(0, typeList.Count - 1)]);
            manager.Record.setELO(getEloFromRegion(worldData.Towns[townIndex].RegionLevel));
            manager.setupHomebase(ref worldData, true);
            worldData.Managers.Add(manager);

            List <Boxer> boxers = WorldBuilderProtocol.generateBoxerRecruits(ref worldData, manager.TownIndex, manager.Record.ELO);

            int   bIndex = 0;
            float max    = 0.0f;

            for (int i = 0; i < boxers.Count; i++)
            {
                float boxerEval = EvaluationProtocol.evaluateBoxer(boxers[i], worldData.Managers[worldData.Managers.Count - 1].Preference);

                if (boxerEval > max)
                {
                    max    = boxerEval;
                    bIndex = i;
                }
            }

            TournamentProtocol.Level boxerLevel = (TournamentProtocol.Level)generateRandomInt(0, (int)worldData.Towns[townIndex].RegionLevel);

            worldData.Boxers.Add(boxers[bIndex]);
            manager.recruitBoxer(worldData.Boxers.Count - 1);
            ManagerProtocol.updateELO(ref worldData, worldData.Managers.Count - 1);
            manager.upgradeFacilities(ref worldData);
            manager.setRank(boxerLevel);
            ageAndDevelop(ref worldData, worldData.Boxers.Count - 1, boxerLevel);

            worldData.Regions[regionIndex].addManager(worldData.Managers.Count - 1);
        }
    }
コード例 #10
0
    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]));
    }