feat: converter reads the Phone library's register statement, named stores and generators
`init phone register` becomes a default (the group chat) plus a function of library calls that runs with the other defaults of a new game (phone_register.py). `init/python [early|hide] in some.store` wraps its code in an in_store node and `default some.store.name` may name a store; yield works as an expression (generator functions are marked gen); `import x as y`, `transform -150 name(...)`, `init:` with if/else, `config.special_namespaces` lines, `at` lists and tuples, transforms made by Python functions, `choice` weights that are expressions, `__len__`/`__bool__`, and the whitelist for os, calendar, itertools, pygame_sdl2 and the new runtime. The converter also records the size of every picture it converts (`imageSizes`) so `renpy.image_size` answers without loading. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e94f9b0d9e
commit
83cc7fdd5c
11 files changed
+379
-26
No files matched your search
@@ -265,3 +265,23 @@ def test_starred_tuple_items_and_pickle_hooks_are_accepted():
|
||||
pgvn.statements(code)
|
||||
assert code[0]["v"]["v"][1] == {"k": "star", "v": {"k": "name", "id": "rest"}}
|
||||
assert [m["name"] for m in code[1]["body"]] == ["run"]
|
||||
|
||||
|
||||
def test_init_phone_register_becomes_a_default_and_a_function_of_library_calls():
|
||||
data = parse('init phone register:\n define "[suz]":\n add "mc" add "suzie"\n icon phone.asset("suzie.png")\n'
|
||||
' as suzieTexts key "suzieTexts"\n label "Earlier"\n time year 2023 month 12 day 25 hour 7 minute 7\n'
|
||||
' "suzie" "Merry Christmas!"\n if flag:\n "mc" "hi"\n else:\n "mc" "no"\n'
|
||||
'label start:\n return\n')
|
||||
assert data.defaults[0][0] == "suzieTexts" and data.defaults[0][1]["f"]["a"] == "GroupChat"
|
||||
assert data.defaults[1][0] == "__phone_register_1_done"
|
||||
function = next(s for s in data.init_code if s.get("op") == "def")
|
||||
assert function["name"] == "__phone_register_1"
|
||||
assert not data.blockers
|
||||
|
||||
|
||||
def test_named_stores_wrap_their_code_and_defaults_may_name_a_store():
|
||||
data = parse('init python in phone.group_chat:\n class GroupChat(object):\n pass\n def make():\n return GroupChat()\n'
|
||||
'default -100 phone.menu = False\nlabel start:\n $ x = phone.group_chat.make()\n return\n')
|
||||
assert data.init_code[0]["op"] == "in_store" and data.init_code[0]["ns"] == "phone.group_chat"
|
||||
assert [s["name"] for s in data.init_code[0]["body"]] == ["GroupChat", "make"]
|
||||
assert data.defaults[0][0] == "phone.menu"
|
||||
Reference in new issue
Block a user