diff --git a/src/game/board.py b/src/game/board.py new file mode 100644 index 0000000..ee36b58 --- /dev/null +++ b/src/game/board.py @@ -0,0 +1,105 @@ +import csv +from pathlib import Path +from typing import List, Optional +from enum import Enum + + +class TechSpeciality(Enum): + GREEN = "GREEN" + RED = "RED" + BLUE = "BLUE" + YELLOW = "YELLOW" + + +class Trait(Enum): + CULTURAL = "CULTURAL" + HAZARDOUS = "HAZARDOUS" + INDUSTRIAL = "INDUSTRIAL" + + +class Planet: + def __init__(self, source: str, name: str, resources: int, influence: int, tech_specialities: List[TechSpeciality], traits: List[Trait], legendary: bool, legendary_ability: Optional[str], home_system: bool, flavour_text: Optional[str]): + self.source: str = source + self.name: str = name + self.resources: int = resources + self.influence: int = influence + self.tech_specialities: List[TechSpeciality] = tech_specialities + self.traits: List[Trait] = traits + self.legendary: bool = legendary + self.legendary_ability: Optional[str] = legendary_ability + self.home_system: bool = home_system + self.flavour_text: Optional[str] = flavour_text + + def __repr__(self): + return f"{self.name} ({self.resources}/{self.influence})" + + def has_green_tech(self): + return TechSpeciality.GREEN in self.tech_specialities + + def has_red_tech(self): + return TechSpeciality.RED in self.tech_specialities + + def has_blue_tech(self): + return TechSpeciality.BLUE in self.tech_specialities + + def has_yellow_tech(self): + return TechSpeciality.YELLOW in self.tech_specialities + + def is_cultural(self): + return Trait.CULTURAL in self.traits + + def is_hazardous(self): + return Trait.HAZARDOUS in self.traits + + def is_industrial(self): + return Trait.INDUSTRIAL in self.traits + + def is_legendary(self): + return self.legendary + +class System: + def __init__(self, id: int, planets: List[Planet], source: str) -> None: + self.id: int = id + self.planets: List[Planet] = planets + self.source: str = source + + def __str__(self) -> str: + return f"{self.id}: ({','.join(map(str,self.planets))})" + + +def read_planets(file_path: str = "data/ti4_planets.csv") -> List[Planet]: + here = Path(__file__).parent + + planets: List[Planet] = [] + with open(here / file_path, newline="") as csvfile: + reader = csv.reader(csvfile, delimiter=";") + next(reader) # Skip header row + for row in reader: + if len(row) >= 9: + source: str = row[0].strip() + name: str = row[1].strip() + traits_str: List[str] = row[2].strip().split(",") + traits: List[Trait] = [] + if (str(Trait.CULTURAL.value) in traits_str): + traits.append(Trait.CULTURAL) + if (str(Trait.HAZARDOUS.value) in traits_str): + traits.append(Trait.HAZARDOUS) + if (str(Trait.INDUSTRIAL.value) in traits_str): + traits.append(Trait.INDUSTRIAL) + legendary: bool = bool(row[3].strip()) + resources: int = int(row[4].strip()) + influence: int = int(row[5].strip()) + tech_str: List[str] = row[6].strip().split(",") + tech: List[TechSpeciality] = [] + if (str(TechSpeciality.BLUE) in tech_str): + tech.append(TechSpeciality.BLUE) + if (str(TechSpeciality.RED) in tech_str): + tech.append(TechSpeciality.RED) + if (str(TechSpeciality.YELLOW) in tech_str): + tech.append(TechSpeciality.YELLOW) + if (str(TechSpeciality.GREEN) in tech_str): + tech.append(TechSpeciality.GREEN) + legendary_ability: str = row[7].strip() + flavour_text: str = row[8].strip() + planets.append(Planet(source, name, resources, influence, tech, traits, legendary, legendary_ability, False, flavour_text)) + return planets diff --git a/src/game/commands.py b/src/game/commands.py index 1a22116..d80d0f8 100644 --- a/src/game/commands.py +++ b/src/game/commands.py @@ -6,6 +6,7 @@ from . import gamelogic from . import factions from . import strategy_cards +from . import board from ..typing import * from discord.ext import commands @@ -25,6 +26,7 @@ def __init__( self.factions = factions.read_factions() self.strategy_cards = strategy_cards.read_strategy_cards() self.logic = gamelogic.GameLogic(bot, engine) + self.planets = board.read_planets() async def __send_embed_or_pretty_err(self, ctx: commands.Context, result: Result[discord.Embed]) -> None: @@ -56,6 +58,14 @@ async def strat_cards( f"{'\n'.join([str(sc) for sc in self.strategy_cards])}" ) + @commands.command(name="planets") + async def list_planets( + self, ctx: commands.Context) -> None: + """Returns the list of planets in the game.""" + + await ctx.send( + f"{'\n'.join([f"{planet.source}: {str(planet)}" for planet in self.planets])}" + ) @commands.command(name="factions") async def random_factions( self, ctx: commands.Context, number: int = 8, *, sources: str = "" diff --git a/src/game/data/ti4_planets.csv b/src/game/data/ti4_planets.csv new file mode 100644 index 0000000..cbf9be1 --- /dev/null +++ b/src/game/data/ti4_planets.csv @@ -0,0 +1,88 @@ +Source;Planet;Traits;Legendary;Resources;Influence;Technology Specialities;Legendary Ability;Flavor Text +Base Game;Abyz;Hazardous;;3;0;;;Its thick, complex atmosphere is inhospitable to most races, but Abyz is known for its seemingly endless natural reserves of rare minerals and precious metals. +Base Game;Fria;Hazardous;;2;0;;;Brutally cold ice world populated only by a few scattered mining camps. Despite brutal climate, highly prized for its deposits of rare ores used in starship drives. +Base Game;Arinam;Industrial;;1;2;;;Isolated planet poor in resources but rich in natural beauty. Boasts many exotic resorts frequented by the rich and famous of the galaxy. +Base Game;Meer;Hazardous;;0;4;Red;;Hellish world immolated in the inferno of its nearby sun. Famed for the fiery majesty of its surface when viewed from the safety of its many orbital stations. +Base Game;Arnor;Industrial;;2;1;;;Lush, green world that is renowned for some of the most fertile soil in the galaxy. Dominated by endless fields and the processing facilities of large agricultural firms. +Base Game;Lor;Industrial;;1;2;;;Wreathed in vast seas of methane ice. Sea floor drilling platforms harvest rare crystals used in advance computers and energy weapons. +Base Game;Bereg;Hazardous;;3;1;;;A frozen world that is inhospitable to most races. Indentured laborers risk attacks from arctic sharaks in the infamous Iodinium mines. +Base Game;Lirta IV;Hazardous;;2;3;;;Covered in vast swamps and fetid bogs. Home to rare biochemical compounds unique to its marshlands used in everything from exotic foods to biogenic drugs. +Base Game;Centauri;Cultural;;1;3;;;Venerable world with few resources but a rich history. Site of important treaties between several races during the Twilight Wars. +Base Game;Gral;Industrial;;1;1;Blue;;Backwater planet with modest resources and an unassuming populace. Most noted for the reliable and affordable vehicles produced in its factories. +Base Game;Coorneeq;Cultural;;1;2;;;Former garden world that has subsequently enjoyed increased industrialization. Home to the esteemed Free Worlds Academy of Military Science and Research. +Base Game;Resculon;Cultural;;2;0;;;Poor in natural resources, but a nearby nexus of major trade routes has brought it increasing wealth as interstellar commerce has intensified. +Base Game;Dal Bootha;Cultural;;0;2;;;A populous planet whose resources have been severely depleted. Well-educated citizenry and many universities, but dependent on foreign imports. +Base Game;Xxehan;Cultural;;1;1;;;Known for genetically complex native lifeforms adapted to tainted atmosphere and biochemistry. +Base Game;Lazar;Industrial;;1;0;Yellow;;The only inhabited world in a forgettable system. Few native resources and only rudimentary, often underdeveloped, industries. +Base Game;Sakulag;Hazardous;;2;1;;;Jungle planet plagued by dangerous predators such as the arboreal razeden. Home to many exotic biochemicals and natural pharmaceuticals. +Base Game;Lodor;Cultural;;3;1;;;Wealthy planet ruled by powerful biotech consortiums. Rumored to harbor hidden caches of outlawed bacterial weapons. +Base Game;Mehar Xull;Hazardous;;1;3;Red;;Unstable radiation belts create hazardous living conditions but facilitate research in the electro-quantum propulsion technologies. +Base Game;Mellon;Cultural;;0;2;;;Poor in natural resources but rich in exotic plant and animal life. Protected as a planetary xenological garden and lifeform preserve. +Base Game;Zohbat;Hazardous;;3;1;;;Known for its highly intoxicating Zohlian whiskey and the planetary space elevator that links the surface with orbital stations and shipyards. +Base Game;New Albion;Industrial;;1;1;Green;;Rare atmospheric composition and biochemistry support lifeforms unlike any others in the galaxy. +Base Game;Starpoint;Hazardous;;3;1;;;Large planet with eight small moons that supply a wide range of valuable resources. Acidic rains and toxic storms make it an unappealing destination for tourists. +Base Game;Quann;Cultural;;2;1;;;Since the discovery of the Alpha Wormhole, this temperate planet with two continents and one large ocean has been a haven for traders and smugglers alike. +Base Game;Qucen'n;Industrial;;1;2;;;After the Twilight Wars, existed for centuries as a near-utopia of scattered communal farms free from governmental interference. +Base Game;Rarron;Cultural;;0;3;;;Large, populous world with three distinctive moons renowned for its biomodification clinics and cyber boutiques. +Base Game;Saudor;Industrial;;2;2;;;Prosperous planet with large native population and substantial industry. Extreme axial tilt results in long day-night cycle that some races find uncomfortable. +Base Game;Tar'Mann;Industrial;;1;1;Green;;Small, isolated planet with small population and modest resources. Most famous for its delicious avinberries. +Base Game;Tequ'ran;Hazardous;;2;0;;;Desolate planet transformed into weapons testing facility for large defense consortiums. +Base Game;Torkan;Cultural;;0;3;;;Populous planet almost completely dependent on foreign imports to sustain the extravagant lifestyles of its citizens. +Base Game;Thibah;Industrial;;1;1;Blue;;Burdened by overpopulation and low mineral content in the planetary crust. Historically used as a staging world for deep-space exploration and trade. +Base Game;Vefut II;Hazardous;;2;2;;;Massive, rocky world cursed with extreme gravity. Underground cities support advanced research in antigravity technologies. +Base Game;Wellon;Industrial;;1;2;Yellow;;Sky cities suspended in helium-rich atmosphere more noted for fantastic views than the small quantities of exotic elements harvested by their chemical mines. +Prophecy of Kings;Archon Vail;Hazardous;;1;3;Blue;;A former Xxcha colony, its extremely low temperatures create exotic molecular compounds that give the world its famed violet hue. Orbital facilities use the compounds in high-energy stardrive research +Prophecy of Kings;Perimeter;Industrial;;2;1;;;Former garrison world with fond memories of the Lazax. Maintains formidable military with informal ties to the Winnu. Perpendicular rings make orbital navigation difficult +Prophecy of Kings;Ang;Industrial;;2;0;Red;;High rotational speed creates extremely energized magnetosphere. Orbital taps use this to energize starship fuels and power labs developing new beam weapons +Prophecy of Kings;Sem-Lore;Cultural;;3;2;Yellow;;Home to the Semanora, and heavily damaged in the Twilight Wars. Rustling warship hulks litter the rod-deserts, making it a war memorial and salvage site +Prophecy of Kings;Vorhal;Cultural;;0;2;Green;;This icy world is wreathed by powerful storms, forcing inhabitants to live underground in geothermal vents. Pacifistic locals award yearly "peace prizes" to peacemakers across the galaxy +Prophecy of Kings;Atlas;Hazardous;;3;1;;;Heavy grav world and former Sol colony famed for squat, strong inhabitants and strategic location. Visitors need support exoskeletons to move on the surface +Prophecy of Kings;Primor;Cultural;Yes;2;1;;You may exhaust this card at the end of your turn to place up to 2 infantry from your reinforcements on any planet you control;Large temperate world. Site of several pitched battles during the Twilight Wars due to valuable osmium deposits and a well- educated populace +Prophecy of Kings;Hope's End;Hazardous;Yes;3;0;;You may exhaust this card at the end of your turn to place 1 mech from your reinforcements on any planet you control, or draw 1 action card;Buried in the Ichal Nebula. The Lazax used the toxic wildlife and fierce aurora storms to train their troops. Even now, volatile weapon caches remain hidden beneath its sands. +Prophecy of Kings;Cormund;Hazardous;;2;0;;;A remote and sparsely settled Naaz-Rokha world destroyed during early entropic field tests. Now mining corporations harvest metals from the shattered core +Prophecy of Kings;Everra;Cultural;;3;1;;;Ancient world of red seas and bare rocks. Locals live in wondrous nano-carbon cities built by a mysterious ancient race, and mine nearby nebulae for rare gases +Prophecy of Kings;Jeol Ir;Industrial;;2;3;;;Heavily industrialized world. Pollution has killed all life outside of dome cities, but twin suns provide constant power for factories and huge populace +Prophecy of Kings;Accoen;Industrial;;2;3;;;Populace lives on continent sized fungal rafts that float atop a soupy, world-spanning ocean of useful bio-compounds. Popular research site for biologists +Prophecy of Kings;Kraag;Hazardous;;2;1;;;A heavily irradiated world known only for its dust mines. Recently a massive "tomb" of dormant Titans was discovered in the southern hemisphere +Prophecy of Kings;Siig;Hazardous;;0;2;;;World covered in frozen, cesium-laced oceans. Archives buried deep beneath the surface use the cold to preserve relics and operate massive computers +Prophecy of Kings;Ba'kal;Industrial;;3;2;;;Dry, rocky deserts stretch from pole to pole. Shield cities protect against sandstorms while supplying nomadic harvester crawlers that mine the barrens for salt compounds +Prophecy of Kings;Alio Prima;Cultural;;1;1;;;Wet planet covered in rivers, lakes and small seas but no oceans. Dry poles provide haven from constant floods. Numerous farms famous for luxury foodstuffs +Prophecy of Kings;Lisis;Industrial;;2;2;;;Primordial world with primitive native life. Potential for terraforming led to the infamous genocide of Saar settlements by Sardakk N'orr and ongoing conflicts between them and Naalu forces +Prophecy of Kings;Velnor;Industrial;;2;1;Red;;Barren world of windswept rocks and thick, murky oceans. Lack of local lifeforms allows corporations to strip-mine the surface and test orbital kinetic weapons at the poles +Prophecy of Kings;Cealdri;Cultural;;0;2;Yellow;;Small cities huddle on the shores of the single ocean and avoid the arid continental interiors. Mentak ships hunt departing vessels carrying bespoke cybernetics +Prophecy of Kings;Xanhact;Hazardous;;0;1;;;Rebelled during the end of the Lazax Empire, and was bombarded to ash by a Lazax fleet as an example. Left by the Galactic Council as a memorial to Lazax tyranny +Prophecy of Kings;Vega Major;Cultural;;2;1;;;Most of the population resides in orbital habitats supporting mining operations in the planetary ring. Surface colonization limited due to oceanic macrosquid infestations +Prophecy of Kings;Vega Minor;Cultural;;1;2;Blue;;Famous for extremely shallow seas covering most of the surface and for the renowned Vega Propulsion Corporation. Stilt cities host vibrant multi-species populations +Prophecy of Kings;Abaddon;Cultural;;1;0;;;A temperate planet whose low gravity allows for stunningly tall mountain ranges. Serves as a stop-over for trade routes to the nearby Vorish Cluster +Prophecy of Kings;Ashtroth;Hazardous;;2;0;;;Covered in boggy landmasses and shallow seas. Algal blooms provide rich biomass for processed foods, but create smelly and often toxic offgassing +Prophecy of Kings;Loki;Cultural;;1;2;;;Cold and wracked with violent storms, Loki still hosts several Yssaril and human colonies, some of which have engaged in escalating shadow-conflicts +Prophecy of Kings;Rigel I;Hazardous;;0;1;;;Hot, innermost world of the Rigel system. Cities and native life cluster inland from the heavily alkaline oceans +Prophecy of Kings;Rigel II;Industrial;;1;2;;;Temperate world with expansive oceans. Covered in estates and resorts for the system's elite, with extensive fisheries that feed much of the rest of the system +Prophecy of Kings;Rigel III;Industrial;;1;1;Green;Outermost world of the Rigel system, and extensively settled despite cooler climates. Boasts a diverse range of industries and research institutions +Discordant Stars;Silence;Industrial;Yes;2;2;;You may exhaust this card at the end of your turn to place 1 cruiser from your reinforcements in any system that contains 1 or more of your ships.; +Discordant Stars;Echo;Hazardous;Yes;1;2;;You may exhaust this card at the end of your turn to place 1 frontier token in a system that does not contain a planet.; +Discordant Stars;Tarrock;Industrial;Yes;3;0;;After an agenda is revealed, you may exhaust this card to predict aloud an outcome of that agenda. If your prediction is correct, draw 1 secret objective.; +Discordant Stars;Prism;Industrial;Yes;0;3;;You may exhaust this card at the end of your turn and purge a non-faction, non-unit upgrade technology you own to gain 1 technology with the same number of prerequisites.; +Discordant Stars;Domna;Hazardous;Yes;2;1;;You may exhaust this card at the end of your turn to remove 1 of your ships from the game board and place that unit in an adjacent system that does not contain another player’s ships.; +Discordant Stars;Troac;Cultural;;0;4;;; +Discordant Stars;Etir V;Hazardous;;4;0;;; +Discordant Stars;Vioss;Cultural;;3;3;;; +Discordant Stars;Fakrenn;Hazardous;;2;2;;; +Discordant Stars;San-Vit;Cultural;;3;1;;; +Discordant Stars;Lodran;Hazardous;;0;2;Yellow;; +Discordant Stars;Dorvok;Industrial;;1;2;Red;; +Discordant Stars;Derbrae;Cultural;;2;3;;; +Discordant Stars;Moln;Industrial;;1;2;Blue;; +Discordant Stars;Rysaa;Hazardous;;2;0;Green;; +Discordant Stars;Salin;Hazardous;;1;2;;; +Discordant Stars;Gwiyun;Hazardous;;2;2;;; +Discordant Stars;Inan;Industrial;;1;2;;; +Discordant Stars;Swog;Industrial;;1;0;;; +Discordant Stars;Detic;Cultural;;3;2;;; +Discordant Stars;Lliot;Cultural;;0;1;;; +Discordant Stars;Qaak;Cultural;;1;1;;; +Discordant Stars;Larred;Industrial;;1;1;;; +Discordant Stars;Nairb;Hazardous;;1;1;;; +Discordant Stars;Sierpen;Cultural;;2;0;;; +Discordant Stars;Mandle;Industrial;;1;1;;; +Discordant Stars;Regnem;Hazardous;;0;2;;; \ No newline at end of file diff --git a/src/game/model.py b/src/game/model.py index 782972b..71e24d1 100644 --- a/src/game/model.py +++ b/src/game/model.py @@ -64,6 +64,7 @@ class Game(models.Base): turn: Mapped[int] = mapped_column(Integer, default=0) + map_string: Mapped[List[int]] = mapped_column(JSON, default=[]) game_players: Mapped[List["GamePlayer"]] = relationship( "GamePlayer", back_populates="game", cascade="all" )