Compare commits

...

28 Commits

Author SHA1 Message Date
Gouvernathor 4de4788b16 Actually do not forgive wrong warper names 2024-04-06 00:50:50 +02:00
Gouvernathor 96767c63ae Fix 2024-04-06 00:49:33 +02:00
Gouvernathor 1a70aff3bc Unnecessary module 2024-04-06 00:46:04 +02:00
Gouvernathor 5f742d4525 Simplify following turning states.dolls into a dict 2024-04-06 00:42:27 +02:00
Gouvernathor e88fda5a2c Use the cds version 2024-04-05 23:38:31 +02:00
Gouvernathor 6b6ad56af4 Update existing code 2024-04-05 23:29:37 +02:00
Gouvernathor 0f80487dfc Remove the register function 2024-04-05 23:28:11 +02:00
Gouvernathor 42d2a17a6a Move the static values to a defined constant
That way it's not saved and it can be upgraded from version to version
2024-04-05 23:26:55 +02:00
Gouvernathor 0d8e91b5a5 Stop using mutable default values for parameters 2024-04-05 23:21:20 +02:00
Gouvernathor 314f971609 Allow poses to be passed to the constructor, and update test script
One problem : it still should not go into a defaulted object
2024-04-05 23:21:01 +02:00
Gouvernathor ec27f91904 Fix lint and prediction 2024-04-05 00:20:21 +02:00
Gouvernathor e129921bc0 Take the doll parameter 2024-04-04 23:34:35 +02:00
Gouvernathor 94b5ea15a5 Better parsing 2024-04-04 23:25:15 +02:00
Gouvernathor 923384eb37 Fix test labels 2024-04-04 23:17:00 +02:00
Gouvernathor c2d8c394a1 Fix cds 2024-04-04 23:15:35 +02:00
Gouvernathor 9befd927a8 fix 2024-04-04 22:58:41 +02:00
Gouvernathor e9ec437d1c Eliminate more uses of eval 2024-04-04 22:55:15 +02:00
Gouvernathor dfd7972752 Avoid using a weak name link 2024-04-04 22:51:02 +02:00
Gouvernathor 1e8f1ebfb8 Use a dict to store the dolls
the existing variable was a set, all the existing use cases still work (contains tests, iteration, turning into lists...)
2024-04-04 22:50:01 +02:00
Gouvernathor 878cec8c76 Simplify some 2024-04-04 22:37:33 +02:00
Gouvernathor b49129ad1f Avoid evals and release name constraint
Name resemblances between two variables should be for the developers' benefit only. If there is a link between data, it should be apparent.
2024-04-04 22:36:46 +02:00
Gouvernathor 34547cb0ad Use an instance storage dict
to avoid main store pollution and evals
2024-04-04 22:34:27 +02:00
Gouvernathor caa4cd0b2c Works without the screens
tested on a save
2024-04-03 01:47:02 +02:00
Gouvernathor cd63abd27b nitwit 2024-04-03 01:42:36 +02:00
Gouvernathor c0bc1cd69f Avoid using screens for chibis
Not exactly sure what to do with the screens for saves compat tbh, should be fine either way and maybe removing the definitions will work
2024-04-03 01:33:13 +02:00
Gouvernathor 00eda2aae5 Simpler syntax 2024-04-03 01:03:54 +02:00
Gouvernathor ae5ff121d9 Moar lint 2024-04-03 01:03:46 +02:00
Gouvernathor 2525bea67d Move the file again 2024-04-03 00:50:26 +02:00
7 changed files with 130 additions and 119 deletions

View File

@ -73,30 +73,42 @@ python early hide:
class chibi:
@staticmethod
def parse(l):
who = l.simple_expression()
action = l.simple_expression()
who = l.require(l.name)
action = l.require(l.name)
arguments = l.arguments() # may be None
l.expect_eol()
return (who, action)
return (who, action, arguments)
def execute(self):
print(f"{self}")
who, action = self
func = eval(f"{who}_chibi.{action}")
print(self)
who, action, arguments = self
chibi = DollChibi.instances[who]
method = getattr(chibi, action)
if arguments is None:
args, kwargs = (), {}
else:
args, kwargs = arguments.evaluate()
method(*args, **kwargs)
# print(f"Execution: {who} {action}")
def lint(self):
who, action = self
try:
chibi = eval(f"{who}_chibi")
except Exception:
who, action, arguments = self
if who not in DollChibi.instances:
renpy.error(f"Character chibi not defined: {who}")
def predict(self):
who, action = self
chibi = DollChibi.instances[who]
chibi = eval(f"{who}_chibi")
doll = eval(f"{who}")
if not hasattr(chibi, action):
renpy.error(f"Chibi action not defined: {who} {action}")
def predict(self):
who, action, arguments = self
chibi = DollChibi.instances[who]
doll = states.dolls[who]
layers = (
l[0] for pose in chibi.poses.keys()
@ -142,6 +154,23 @@ python early hide:
return {"blocks": blocks}
def lint(self):
any_true = False
for block, weight, condition in self["blocks"]:
if not isinstance(weight, (int, float)):
renpy.error(f"Weight must be a number, not {weight!r}")
if condition == "True":
any_true = True
else:
try:
eval(condition)
except Exception:
renpy.error(f"Condition could not be evaluated: {condition!r}")
if not any_true:
renpy.error("All blocks have a condition, which will raise an exception if all conditions are False at the same time at runtime")
def next(self):
blocks = [(block, weight) for block, weight, condition in self["blocks"] if eval(condition)]
total_weight = sum(weight for _, weight in blocks)

View File

@ -2115,7 +2115,7 @@ label gryffindor_match_return:
hoo "Oh, look at the time. I think I better get going--" ("open", "shocked", "shocked", "R")
#hooch sprints out the office sound
$ hooch_chibi.hide()
chibi hooch hide
play sound "sounds/run_03.ogg"
pause 1.0
play sound "sounds/door.ogg"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,4 @@ init python:
char.set_face(mouth="base", eyes="base", eyebrows="base", pupils="mid", cheeks="none", tears="none")
def chibi_init():
# TODO: Perhaps it could be automated?
hooch_chibi.register("stand", 1, (600, 800))
hooch_chibi.register("walk", 8, (600, 800))
config.start_callbacks.extend([wardrobe_init, chibi_init])
config.start_callbacks.append(wardrobe_init)

View File

@ -1,3 +1,5 @@
define states.dolls = {}
init python:
class Doll(DollMethods):
# 0 - 50 = Skin/Body Layers
@ -77,15 +79,11 @@ init python:
self.build_image()
# Add doll name to global doll states store
try:
renpy.store.states.dolls.add(name)
except AttributeError:
renpy.store.states.dolls = {name}
states.dolls[name] = self
def generate_hash(self):
clothes_hash = str([x[0]._hash for x in self.states.values() if istype(x[0], (DollCloth, DollClothDynamic, DollMakeup)) and x[2]])
salt = str( [self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash] )
salt = str([self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash])
return hash(salt)
def show(self, force=False, ignore_skipping=False):

View File

@ -23,7 +23,7 @@ init -1 python:
def get_character_object(key):
__check_exists(key)
return getattr(store, key)
return states.dolls[key]
def get_character_outfit(key, typ="default"):
__check_exists(key)