mirror of
https://gitlab.com/the-no-frauds-club/cosmonarchy-bw-prerelease.git
synced 2026-09-17 01:01:12 +00:00
142 lines
5.9 KiB
Lua
142 lines
5.9 KiB
Lua
local TerranArmor = require("melee.terran.armor")
|
|
local TerranRaider = require("melee.terran.raider")
|
|
local TerranOrbital = require("melee.terran.orbital")
|
|
local TerranGeneral = require("melee.terran.general")
|
|
|
|
local ZergAssault = require("melee.zerg.assault")
|
|
local ZergSwarm = require("melee.zerg.swarm")
|
|
local ZergSunblot = require("melee.zerg.sunblot")
|
|
local ZergGeneral = require("melee.zerg.general")
|
|
|
|
local ProtossRanger = require("melee.protoss.ranger")
|
|
local ProtossTemplar = require("melee.protoss.templar")
|
|
local ProtossSkylord = require("melee.protoss.skylord")
|
|
local ProtossGeneral = require("melee.protoss.general")
|
|
|
|
---@class Personalities
|
|
Personalities = {
|
|
Terran = {
|
|
ArmorTankPush = TerranArmor.tank_push,
|
|
ArmorFeFiveFulc = TerranArmor.fe_five_fulc,
|
|
ArmorTwoFulcVulture = TerranArmor.two_fulc_vulture,
|
|
ArmorWalkerPower = TerranArmor.walker_power,
|
|
ArmorIronCrusade = TerranArmor.iron_crusade,
|
|
ArmorDavidAndGoliath = TerranArmor.david_and_goliath,
|
|
RaiderEightRax = TerranRaider.eight_rax,
|
|
RaiderThreeRaxBio = TerranRaider.three_rax_bio,
|
|
RaiderFastAnvil = TerranRaider.fast_anvil,
|
|
RaiderFourRaxPressure = TerranRaider.four_rax_pressure,
|
|
RaiderUprising = TerranRaider.uprising,
|
|
RaiderHolyAckmeds = TerranRaider.holy_ackmeds,
|
|
OrbitalRapidStarpads = TerranOrbital.rapid_starpads,
|
|
OrbitalTheDon = TerranOrbital.the_don,
|
|
OrbitalWraithBio = TerranOrbital.wraith_bio,
|
|
OrbitalHotdrop = TerranOrbital.hotdrop,
|
|
OrbitalSuddenStarport = TerranOrbital.sudden_starport,
|
|
OrbitalAcesHigh = TerranOrbital.aces_high,
|
|
GeneralTwoFulcrumMech = TerranGeneral.two_fulcrum_mech,
|
|
GeneralEarlyRiser = TerranGeneral.early_riser,
|
|
GeneralTheCube = TerranGeneral.the_cube,
|
|
GeneralDoublingUp = TerranGeneral.doubling_up,
|
|
GeneralMechIntoAir = TerranGeneral.mech_into_air,
|
|
GeneralObservant = TerranGeneral.observant,
|
|
},
|
|
Zerg = {
|
|
AssaultThreeBaseHydrith = ZergAssault.three_base_hydrith,
|
|
AssaultTwoBaseZorkiz = ZergAssault.two_base_zorkiz,
|
|
AssaultTwoBaseHydrithQuazeth = ZergAssault.two_base_hydrith_quazeth,
|
|
AssaultTwoBaseAlkag = ZergAssault.two_base_alkag,
|
|
AssaultPotency = ZergAssault.potency,
|
|
AssaultEarthenTides = ZergAssault.earthen_tides,
|
|
SwarmThreeBaseFlood = ZergSwarm.three_base_flood,
|
|
SwarmThreeBaseUltrav = ZergSwarm.three_base_ultrav,
|
|
SwarmInstantQuazeth = ZergSwarm.instant_quazeth,
|
|
SwarmThreeBaseOthstol = ZergSwarm.three_base_othstol,
|
|
SwarmGatesOfHell = ZergSwarm.gates_of_hell,
|
|
SwarmPrimitivePressure = ZergSwarm.primitive_pressure,
|
|
SunblotBigAndLittle = ZergSunblot.big_and_little,
|
|
SunblotTheTriad = ZergSunblot.the_triad,
|
|
SunblotSkitteringDuo = ZergSunblot.skittering_duo,
|
|
SunblotEarlyBirds = ZergSunblot.early_birds,
|
|
SunblotFlyingFeint = ZergSunblot.flying_feint,
|
|
SunblotDescendingHorizon = ZergSunblot.descending_horizon,
|
|
GeneralSleepingGiant = ZergGeneral.sleeping_giant,
|
|
GeneralShriekingSwarm = ZergGeneral.shrieking_swarm,
|
|
GeneralSubjugation = ZergGeneral.subjugation,
|
|
GeneralBeforeTheStorm = ZergGeneral.before_the_storm,
|
|
GeneralTimeAfterTime = ZergGeneral.time_after_time,
|
|
GeneralConstrainedCoil = ZergGeneral.constrained_coil,
|
|
},
|
|
Protoss = {
|
|
RangerTwoGateStrider = ProtossRanger.two_gate_strider,
|
|
RangerEmissarySquared = ProtossRanger.emissary_squared,
|
|
RangerOneGateAuthority = ProtossRanger.one_gate_authority,
|
|
RangerLatticeExpo = ProtossRanger.lattice_expo,
|
|
RangerSimulantSwarm = ProtossRanger.simulant_swarm,
|
|
RangerTheRegistry = ProtossRanger.the_registry,
|
|
TemplarThreeGateStrider = ProtossTemplar.three_gate_strider,
|
|
TemplarSuffocatingShadow = ProtossTemplar.suffocating_shadow,
|
|
TemplarLegion = ProtossTemplar.legion,
|
|
TemplarInitiates = ProtossTemplar.initiates,
|
|
TemplarMartyrdom = ProtossTemplar.martyrdom,
|
|
TemplarLegionsHeralds = ProtossTemplar.legions_heralds,
|
|
SkylordSolarEscort = ProtossSkylord.solar_escort,
|
|
SkylordDeadlyOmen = ProtossSkylord.deadly_omen,
|
|
SkylordTwoGatePanoptus = ProtossSkylord.two_gate_panoptus,
|
|
SkylordExalted = ProtossSkylord.exalted,
|
|
SkylordSorrowFleet = ProtossSkylord.sorrow_fleet,
|
|
SkylordShipsAndSwords = ProtossSkylord.ships_and_swords,
|
|
GeneralLunaticLegion = ProtossGeneral.lunatic_legion,
|
|
GeneralStridentStriders = ProtossGeneral.strident_striders,
|
|
GeneralWorship = ProtossGeneral.worship,
|
|
GeneralRoboticsFe = ProtossGeneral.robotics_fe,
|
|
GeneralTheSwordsmiths = ProtossGeneral.the_swordsmiths,
|
|
GeneralMatriarchy = ProtossGeneral.matriarchy,
|
|
},
|
|
Askosi = {},
|
|
}
|
|
|
|
---@class RacePersonalities
|
|
|
|
---@param race RaceId
|
|
---@return RacePersonalities
|
|
local function by_race(race)
|
|
if race == RaceId.Terran then
|
|
return Personalities.Terran
|
|
elseif race == RaceId.Zerg then
|
|
return Personalities.Zerg
|
|
elseif race == RaceId.Protoss then
|
|
return Personalities.Protoss
|
|
elseif race == RaceId.Askosi then
|
|
return Personalities.Askosi
|
|
end
|
|
error("Race " .. tostring(race) .. " is not a valid AI race")
|
|
end
|
|
|
|
---@param dict table
|
|
---@return AIPersonality
|
|
local function pick_random(dict)
|
|
local keys = {}
|
|
for key, _ in pairs(dict) do
|
|
table.insert(keys, key)
|
|
end
|
|
local random_key = keys[math.random(#keys)]
|
|
return dict[random_key]
|
|
end
|
|
|
|
---@param player? Player
|
|
---@return AIPersonality
|
|
function Personalities.pick_random(player)
|
|
player = player or Player()
|
|
local race_personalities = by_race(player.race)
|
|
return pick_random(race_personalities)
|
|
end
|
|
|
|
---@param personality AIPersonality
|
|
---@return AIPersonality
|
|
function Personalities.copy(personality)
|
|
error("not implemented yet")
|
|
end
|
|
|
|
return Personalities
|