Skip to content

Commit

Permalink
SPS 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afellowcorn committed Jul 2, 2024
1 parent f468328 commit c614df5
Show file tree
Hide file tree
Showing 110 changed files with 306 additions and 166 deletions.
18 changes: 17 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def log_crash(logtype, value, tb):
else:
print("Running on PyInstaller build")

print("Version Name: ", VERSION_NAME)
print("ClanGen Version Name: ", VERSION_NAME)
print("Running on commit " + get_version_info().version_number)

# Load game
Expand All @@ -170,6 +170,22 @@ def log_crash(logtype, value, tb):
import pygame_gui
import pygame

print("")
print("Running on SPS Framework")
print(" Version: " + get_version_info().sps_version)
print(" Species detected: " + str(len(game.species["species"])))
print(" Sprite folders detected: " + str(len(game.sprite_folders)))
if len(game.species["ran_weights"]) == len(game.species["species"]):
print(" ran_weights amount: correct")
else:
print(" ran_weights amount: incorrect")
if len(game.species["in_weights"]) == len(game.species["species"]):
print(" in_weights amount: correct")
else:
print(" in_weights amount: incorrect")
print("Created by a.corn(afellowcorn)")
print("Official documentation: https://docs.google.com/document/d/1ZwXM-e1TEsUr7tzTtXxek-AKO8e3gGARRiW6JeevShc")
print("")

# import all screens for initialization (Note - must be done after pygame_gui manager is created)
from scripts.screens.all_screens import (
Expand Down
10 changes: 10 additions & 0 deletions resources/credits_text.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"sps_text": [
"<b>SPS Framework</b>",
"",
"This is a ClanGen mod framework meant to give an easier and uniform way for modders to create mods with multiple species that use unique spritesheets.",
"It also allows for easily adding constraints utlizing the species attribute.",
"",
"<b>Created by:</b> a.corn(afellowcorn)",
"_",
""
],
"text": [
"<b>Welcome to Warrior Cats Clan generator!</b>",
"",
Expand Down
16 changes: 16 additions & 0 deletions resources/species.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"species": [
"species1",
"species2"
],
"ran_weights": [1, 1],
"in_weights": {
"species1": [1, 1],
"species2": [1, 1]
},
"comment": [
"ran_weights are used in species randomization, in_weights are used in inheritance.",
"species name before the weights is the parent's species, the weights from both parents are added together.",
"all weights follow the order of the species list."
]
}
48 changes: 48 additions & 0 deletions scripts/cat/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ def __init__(
self,
prefix=None,
gender=None,
species=None,
status="newborn",
backstory="clanborn",
parent1=None,
parent2=None,
par2species=None,
suffix=None,
specsuffix_hidden=False,
ID=None,
Expand Down Expand Up @@ -188,6 +190,7 @@ def __init__(

# Public attributes
self.gender = gender
self.species = species
self.status = status
self.backstory = backstory
self.age = None
Expand All @@ -197,6 +200,7 @@ def __init__(
)
self.parent1 = parent1
self.parent2 = parent2
self.par2species = par2species
self.adoptive_parents = []
self.pelt = pelt if pelt else Pelt()
self.former_mentor = []
Expand Down Expand Up @@ -262,6 +266,14 @@ def __init__(
else:
self.ID = ID

# species
if species is None:
species_list = game.species["species"]
weights = game.species["ran_weights"]
in_weights = game.species["in_weights"]

Cat.generate_species(self, species_list, weights, in_weights, self.par2species if self.par2species else None, [Cat.fetch_cat(i) for i in (self.parent1, self.parent2) if i])

# age and status
if status is None and moons is None:
self.age = choice(self.ages)
Expand Down Expand Up @@ -478,6 +490,40 @@ def init_generate_cat(self, skill_dict):
if not skill_dict:
self.skills = CatSkills.generate_new_catskills(self.status, self.moons)

def generate_species(self, species_list, weights, in_weights, par2species, parents:tuple=()):
if parents:
par_species = set()
par_weights = []
for x in range(0, len(weights)):
par_weights.append(0)

# collect species of parents
for p in parents:
if p:
par_species.add(p.species)

# par2species is generated when parent2 is None
if par2species:
print("par2species: "+par2species)
par_species.add(par2species)

if not par_species:
print("Warning - par_species none: species randomized")
self.species = choices(species_list, weights=weights, k=1)[0]

print("par_species = "+str(par_species))

# get inheritance weights and add them together
for s in par_species:
for x in range(0, len(weights)):
add_weight = in_weights[s]
par_weights[x] += add_weight[x]
print(par_weights)

self.species = choices(species_list, weights=par_weights, k=1)[0]
else:
self.species = choices(species_list, weights=weights, k=1)[0]

def __repr__(self):
return "CAT OBJECT:" + self.ID

Expand Down Expand Up @@ -3319,6 +3365,7 @@ def get_save_dict(self, faded=False):
"ID": self.ID,
"name_prefix": self.name.prefix,
"name_suffix": self.name.suffix,
"species": self.species,
"status": self.status,
"moons": self.moons,
"dead_for": self.dead_for,
Expand All @@ -3338,6 +3385,7 @@ def get_save_dict(self, faded=False):
"gender_align": self.genderalign,
"pronouns": self.pronouns,
"birth_cooldown": self.birth_cooldown,
"species": self.species,
"status": self.status,
"backstory": self.backstory if self.backstory else None,
"moons": self.moons,
Expand Down
Loading

0 comments on commit c614df5

Please sign in to comment.