karni-game 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- karni_game-0.6.0/.gitignore +44 -0
- karni_game-0.6.0/LICENSE +201 -0
- karni_game-0.6.0/PKG-INFO +119 -0
- karni_game-0.6.0/README.md +86 -0
- karni_game-0.6.0/karni_game/AGENTS.fragment.md +13 -0
- karni_game-0.6.0/karni_game/__init__.py +29 -0
- karni_game-0.6.0/karni_game/admin.py +206 -0
- karni_game-0.6.0/karni_game/api.py +887 -0
- karni_game-0.6.0/karni_game/apps.py +43 -0
- karni_game-0.6.0/karni_game/checks.py +75 -0
- karni_game-0.6.0/karni_game/clock.py +59 -0
- karni_game-0.6.0/karni_game/conf.py +96 -0
- karni_game-0.6.0/karni_game/config.py +119 -0
- karni_game-0.6.0/karni_game/cors.py +73 -0
- karni_game-0.6.0/karni_game/daily.py +127 -0
- karni_game-0.6.0/karni_game/errorcodes.py +404 -0
- karni_game-0.6.0/karni_game/errors.py +47 -0
- karni_game-0.6.0/karni_game/events.py +138 -0
- karni_game-0.6.0/karni_game/gamesettings.py +76 -0
- karni_game-0.6.0/karni_game/hooks.py +142 -0
- karni_game-0.6.0/karni_game/intents.py +110 -0
- karni_game-0.6.0/karni_game/karni.module.toml +124 -0
- karni_game-0.6.0/karni_game/merge.py +213 -0
- karni_game-0.6.0/karni_game/messages.py +36 -0
- karni_game-0.6.0/karni_game/migrations/0001_initial.py +59 -0
- karni_game-0.6.0/karni_game/migrations/0002_saves.py +39 -0
- karni_game-0.6.0/karni_game/migrations/0003_boards_and_scores.py +119 -0
- karni_game-0.6.0/karni_game/migrations/0004_wallet_rewards_items.py +197 -0
- karni_game-0.6.0/karni_game/migrations/0005_streaks.py +37 -0
- karni_game-0.6.0/karni_game/migrations/0006_achievements_missions.py +124 -0
- karni_game-0.6.0/karni_game/migrations/0007_config.py +40 -0
- karni_game-0.6.0/karni_game/migrations/0008_score_review_index.py +19 -0
- karni_game-0.6.0/karni_game/migrations/0009_matches.py +31 -0
- karni_game-0.6.0/karni_game/migrations/0010_game_from_parent.py +34 -0
- karni_game-0.6.0/karni_game/migrations/0011_score_played_at.py +23 -0
- karni_game-0.6.0/karni_game/migrations/0012_anonymous_intents.py +31 -0
- karni_game-0.6.0/karni_game/migrations/0013_reward_trust.py +31 -0
- karni_game-0.6.0/karni_game/migrations/0014_intent_kind_length.py +18 -0
- karni_game-0.6.0/karni_game/migrations/__init__.py +0 -0
- karni_game-0.6.0/karni_game/models.py +1077 -0
- karni_game-0.6.0/karni_game/multiplayer.py +166 -0
- karni_game-0.6.0/karni_game/people.py +94 -0
- karni_game-0.6.0/karni_game/players.py +306 -0
- karni_game-0.6.0/karni_game/preferences.py +25 -0
- karni_game-0.6.0/karni_game/progress.py +287 -0
- karni_game-0.6.0/karni_game/rewards.py +233 -0
- karni_game-0.6.0/karni_game/roles.py +72 -0
- karni_game-0.6.0/karni_game/saves.py +224 -0
- karni_game-0.6.0/karni_game/scores.py +349 -0
- karni_game-0.6.0/karni_game/sellables.py +86 -0
- karni_game-0.6.0/karni_game/shop.py +136 -0
- karni_game-0.6.0/karni_game/signatures.py +67 -0
- karni_game-0.6.0/karni_game/tasks.py +21 -0
- karni_game-0.6.0/karni_game/templates/karni_game/admin/grant.html +13 -0
- karni_game-0.6.0/karni_game/templates/karni_game/email/achievement_unlocked_body.txt +3 -0
- karni_game-0.6.0/karni_game/templates/karni_game/email/achievement_unlocked_subject.txt +1 -0
- karni_game-0.6.0/karni_game/throttling.py +45 -0
- karni_game-0.6.0/karni_game/urls.py +48 -0
- karni_game-0.6.0/karni_game/viewsets.py +312 -0
- karni_game-0.6.0/karni_game/wallet.py +147 -0
- karni_game-0.6.0/pyproject.toml +102 -0
- karni_game-0.6.0/ui/.gitignore +6 -0
- karni_game-0.6.0/ui/.prettierignore +5 -0
- karni_game-0.6.0/ui/.prettierrc +6 -0
- karni_game-0.6.0/ui/LICENSE +201 -0
- karni_game-0.6.0/ui/README.md +146 -0
- karni_game-0.6.0/ui/bin/karni-game.js +5 -0
- karni_game-0.6.0/ui/client.d.ts +26 -0
- karni_game-0.6.0/ui/eslint.config.js +45 -0
- karni_game-0.6.0/ui/example/block-hopper/index.html +14 -0
- karni_game-0.6.0/ui/example/block-hopper/src/core.ts +158 -0
- karni_game-0.6.0/ui/example/block-hopper/src/main.ts +218 -0
- karni_game-0.6.0/ui/example/block-hopper/src/style.css +21 -0
- karni_game-0.6.0/ui/example/block-hopper/vite.config.ts +22 -0
- karni_game-0.6.0/ui/package-lock.json +4532 -0
- karni_game-0.6.0/ui/package.json +151 -0
- karni_game-0.6.0/ui/src/audio/audio.ts +289 -0
- karni_game-0.6.0/ui/src/audio/index.ts +2 -0
- karni_game-0.6.0/ui/src/client/client.ts +1087 -0
- karni_game-0.6.0/ui/src/client/index.ts +21 -0
- karni_game-0.6.0/ui/src/client/local.ts +357 -0
- karni_game-0.6.0/ui/src/client/queue.ts +163 -0
- karni_game-0.6.0/ui/src/client/transport.ts +145 -0
- karni_game-0.6.0/ui/src/client/types.ts +290 -0
- karni_game-0.6.0/ui/src/engines/phaser.ts +106 -0
- karni_game-0.6.0/ui/src/engines/pixi.ts +93 -0
- karni_game-0.6.0/ui/src/engines/r3f.tsx +185 -0
- karni_game-0.6.0/ui/src/index.ts +11 -0
- karni_game-0.6.0/ui/src/input/index.ts +4 -0
- karni_game-0.6.0/ui/src/input/input.ts +301 -0
- karni_game-0.6.0/ui/src/input/stick.ts +150 -0
- karni_game-0.6.0/ui/src/internal/emitter.ts +38 -0
- karni_game-0.6.0/ui/src/internal/time.ts +61 -0
- karni_game-0.6.0/ui/src/portal/adapters/crazygames.ts +98 -0
- karni_game-0.6.0/ui/src/portal/adapters/fake.ts +93 -0
- karni_game-0.6.0/ui/src/portal/adapters/gamedistribution.ts +126 -0
- karni_game-0.6.0/ui/src/portal/adapters/none.ts +15 -0
- karni_game-0.6.0/ui/src/portal/adapters/poki.ts +48 -0
- karni_game-0.6.0/ui/src/portal/adapters/y8.ts +124 -0
- karni_game-0.6.0/ui/src/portal/index.ts +14 -0
- karni_game-0.6.0/ui/src/portal/link.ts +58 -0
- karni_game-0.6.0/ui/src/portal/portal.ts +251 -0
- karni_game-0.6.0/ui/src/portal/script.ts +32 -0
- karni_game-0.6.0/ui/src/portal/sdks.ts +10 -0
- karni_game-0.6.0/ui/src/portal/types.ts +123 -0
- karni_game-0.6.0/ui/src/rng/date.ts +39 -0
- karni_game-0.6.0/ui/src/rng/index.ts +4 -0
- karni_game-0.6.0/ui/src/rng/rng.ts +83 -0
- karni_game-0.6.0/ui/src/runtime/fixed-step.ts +68 -0
- karni_game-0.6.0/ui/src/runtime/index.ts +10 -0
- karni_game-0.6.0/ui/src/runtime/loop.ts +162 -0
- karni_game-0.6.0/ui/src/runtime/pause.ts +45 -0
- karni_game-0.6.0/ui/src/runtime/reasons.ts +39 -0
- karni_game-0.6.0/ui/src/runtime/view.ts +218 -0
- karni_game-0.6.0/ui/src/save/index.ts +5 -0
- karni_game-0.6.0/ui/src/save/save.ts +178 -0
- karni_game-0.6.0/ui/src/save/storage.ts +149 -0
- karni_game-0.6.0/ui/src/save/types.ts +11 -0
- karni_game-0.6.0/ui/src/smoke/index.ts +246 -0
- karni_game-0.6.0/ui/src/tooling/checks.ts +233 -0
- karni_game-0.6.0/ui/src/tooling/cli.ts +124 -0
- karni_game-0.6.0/ui/src/tooling/config.ts +95 -0
- karni_game-0.6.0/ui/src/tooling/index.ts +20 -0
- karni_game-0.6.0/ui/src/tooling/package.ts +116 -0
- karni_game-0.6.0/ui/src/tooling/portals.ts +148 -0
- karni_game-0.6.0/ui/src/tooling/vite.ts +199 -0
- karni_game-0.6.0/ui/src/tooling/zip.ts +90 -0
- karni_game-0.6.0/ui/tests-browser/block-hopper.test.ts +134 -0
- karni_game-0.6.0/ui/tsconfig.json +46 -0
- karni_game-0.6.0/ui/vite.config.ts +59 -0
- karni_game-0.6.0/ui/vitest.config.ts +23 -0
- karni_game-0.6.0/ui/vitest.smoke.config.ts +12 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.learning/
|
|
2
|
+
|
|
3
|
+
# Python
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
|
|
15
|
+
# Build artifacts
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
packages/karni-cli/karni_cli/_templates/
|
|
19
|
+
packages/karni-cli/karni_cli/_agent/
|
|
20
|
+
packages/karni-cli/karni_cli/_changelog/
|
|
21
|
+
packages/karni-cli/karni_cli/_errorcodes/
|
|
22
|
+
packages/karni-cli/karni_cli/_settings/
|
|
23
|
+
packages/karni-cli/karni_cli/_catalog/
|
|
24
|
+
packages/karni-cli/karni_cli/_ui/
|
|
25
|
+
|
|
26
|
+
# Node
|
|
27
|
+
node_modules/
|
|
28
|
+
storybook-static/
|
|
29
|
+
*.tsbuildinfo
|
|
30
|
+
|
|
31
|
+
# Local env / editor / tooling
|
|
32
|
+
.env
|
|
33
|
+
.env.*
|
|
34
|
+
!.env.example
|
|
35
|
+
.DS_Store
|
|
36
|
+
.idea/
|
|
37
|
+
|
|
38
|
+
# MkDocs build output
|
|
39
|
+
site/
|
|
40
|
+
.github/ci/prod_e2e/test-results/
|
|
41
|
+
|
|
42
|
+
# Contributors' own agent working files stay on their machines
|
|
43
|
+
/CLAUDE.md
|
|
44
|
+
/.claude/
|
karni_game-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Chandrabhan Shekhawat, Gigai Kripa Services (https://gigaikripaservices.com)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: karni-game
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Games for Karni: guest players, cloud saves, leaderboards, a soft-currency wallet, daily content and achievements, with a realtime server contract. Karni is an open-source Django + React framework for building with AI coding agents. Your agent writes only your domain. The API, admin, permissions and React screens come from a package you upgrade, not code it rewrites in each project. One rule set covers every coding agent. The build fails when an agent hand-writes what Karni ships.
|
|
5
|
+
Project-URL: Homepage, https://github.com/cbsshekhawat18-lab/karni
|
|
6
|
+
Project-URL: Documentation, https://cbsshekhawat18-lab.github.io/karni/
|
|
7
|
+
Project-URL: Repository, https://github.com/cbsshekhawat18-lab/karni
|
|
8
|
+
Project-URL: Issues, https://github.com/cbsshekhawat18-lab/karni/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/cbsshekhawat18-lab/karni/tree/main/docs/migrations
|
|
10
|
+
Author-email: Chandrabhan Shekhawat <cbsshekhawat18@gmail.com>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: achievements,cloud save,django,game,karni,leaderboard,react
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Web Environment
|
|
16
|
+
Classifier: Framework :: Django
|
|
17
|
+
Classifier: Framework :: Django :: 5.2
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Games/Entertainment
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Requires-Dist: karni<0.7,>=0.6
|
|
29
|
+
Requires-Dist: pyjwt>=2.8
|
|
30
|
+
Provides-Extra: commerce
|
|
31
|
+
Requires-Dist: karni-commerce<0.7,>=0.6; extra == 'commerce'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# karni-game
|
|
35
|
+
|
|
36
|
+
Games for Karni: guest players, cloud saves, leaderboards, a soft-currency wallet, daily content and achievements, with a realtime server contract.
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/karni-game/) [](https://github.com/cbsshekhawat18-lab/karni/blob/main/LICENSE) [](https://cbsshekhawat18-lab.github.io/karni/game/)
|
|
39
|
+
|
|
40
|
+
The server side of a game, for any game a project hosts. The server decides every reward, every price and every balance: a client only reports and asks. It is **experimental**: its names may change in a minor release, with a CHANGELOG entry.
|
|
41
|
+
|
|
42
|
+
The guide is [docs/game.md](https://cbsshekhawat18-lab.github.io/karni/game/), and the HTTP contract a client, a realtime server and a portal code against is [docs/game-api.md](https://cbsshekhawat18-lab.github.io/karni/game-api/).
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install karni-game # karni-game[commerce] for real-money items
|
|
48
|
+
karni add game
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A player is a person of the people contract, so set it above the settings call, and mount the API once:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
# config/settings.py
|
|
55
|
+
KARNI_PEOPLE = True
|
|
56
|
+
|
|
57
|
+
# config/urls.py, before path("api/", include("karni.api.urls"))
|
|
58
|
+
path("api/game/", include("karni_game.urls")),
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Then `make migrate`. `karni new "Block Hopper" --kind game` writes all of it, with a `games` app, the game in `content/game.yaml` and a page at `/game`.
|
|
62
|
+
|
|
63
|
+
## What it adds
|
|
64
|
+
|
|
65
|
+
| Part | What |
|
|
66
|
+
|---|---|
|
|
67
|
+
| Players | `Player` on `people.Person`: a guest with a token the server issues, an account once its email is verified, an upgrade that keeps the guest's progress (`people.merge` with the module's merge hook). |
|
|
68
|
+
| Saves | `Save`: versioned JSON per player, game and slot, a server version counter (409 with the server's copy on a stale write), a size limit, save migrations per game. |
|
|
69
|
+
| Boards | `Board`, `Score`, `Best`: periods on the game's clock, plausible ranges, runs (seed and input log) kept for review, flagged runs, run checks. |
|
|
70
|
+
| Wallet | `Currency`, `Wallet`, `LedgerEntry`: atomic and capped, a ledger entry with a reason for every move. |
|
|
71
|
+
| Rewards and shop | `Reward`, `Claim`, `Item`, `Ownership`: rewards declared on the server (daily, ad with a signed portal callback, mission, achievement, match, staff), cosmetics owned and equipped, a shop in soft currency, real-money items as the karni-commerce kind `game_item`. |
|
|
72
|
+
| Daily | `Streak`: the server's date, a daily seed per game, streaks with a grace rule, a daily board. |
|
|
73
|
+
| Achievements | `Achievement`, `Mission`, `Progress`, `Unlock`, `Completion`: counters the game reports, unlocked and granted by the server. |
|
|
74
|
+
| Config | `ConfigValue`: remote config and feature flags with a rollout, in the one boot call. Analytics checked against the game's schema and published as `game.analytics.tracked`. |
|
|
75
|
+
| Multiplayer | `Match`: a short-lived HS256 player token for a realtime server of your own, and its signed results report. |
|
|
76
|
+
|
|
77
|
+
The admin ships explicit classes (`karni_game/admin.py`) for players, scores, wallets and the ledger, where staff act. The other models use the derived admin. Two roles come with it (`game-manager`, `game-moderator`, the `karni.roles` entry point).
|
|
78
|
+
|
|
79
|
+
## Settings
|
|
80
|
+
|
|
81
|
+
| Setting | Env var | Default | Meaning |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `KARNI_GAME_RATES` | | the defaults of docs/game-api.md | rates of the limited writes, by scope (`None` turns one off) |
|
|
84
|
+
| `KARNI_GAME_TOKEN_HEADER` | `KARNI_GAME_TOKEN_HEADER` | `X-Player-Token` | the guest token's header |
|
|
85
|
+
| `KARNI_GAME_CORS_ORIGINS` | `KARNI_GAME_CORS_ORIGINS` | `[]` | origins a portal build calls `/api/game/` from (tokens only) |
|
|
86
|
+
| `KARNI_GAME_SERVER_SECRET` | `KARNI_GAME_SERVER_SECRET` | blank | the realtime server's shared secret (at least 32 bytes). Blank: no multiplayer |
|
|
87
|
+
| `KARNI_GAME_TOKEN_ISSUER` | `KARNI_GAME_TOKEN_ISSUER` | `karni-game` | the player token's `iss` |
|
|
88
|
+
| `KARNI_GAME_TOKEN_SECONDS` | `KARNI_GAME_TOKEN_SECONDS` | `300` | the player token's life |
|
|
89
|
+
| `KARNI_GAME_PORTALS` | | `{}` | portals that call back after an ad: `{name: {"secret", "verifier"}}` |
|
|
90
|
+
| `KARNI_GAME_SIGNATURE_TOLERANCE` | `KARNI_GAME_SIGNATURE_TOLERANCE` | `300` | seconds a signed request's timestamp may be off |
|
|
91
|
+
| `KARNI_GAME_AD_INTENT_SECONDS` | `KARNI_GAME_AD_INTENT_SECONDS` | `3600` | an ad reward intent's life |
|
|
92
|
+
| `KARNI_GAME_CLIENT_CLAIMS_PER_DAY` | `KARNI_GAME_CLIENT_CLAIMS_PER_DAY` | `5` | the cap of a client-claimed ad reward |
|
|
93
|
+
| `KARNI_GAME_INTENT_DAYS` | `KARNI_GAME_INTENT_DAYS` | `7` | days a retry key is kept |
|
|
94
|
+
| `KARNI_GAME_MAX_SAVE_BYTES` | `KARNI_GAME_MAX_SAVE_BYTES` | `1048576` | the largest save any game allows |
|
|
95
|
+
| `KARNI_GAME_MAX_RUN_BYTES` | `KARNI_GAME_MAX_RUN_BYTES` | `262144` | the largest run record |
|
|
96
|
+
| `KARNI_GAME_MERGER` | `KARNI_GAME_MERGER` | `karni_game.merge.Merger` | the merge rules of two players |
|
|
97
|
+
| `KARNI_GAME_DAILY_SEED` | `KARNI_GAME_DAILY_SEED` | `karni_game.daily.daily_seed` | `seed(game, day) -> int` |
|
|
98
|
+
| `KARNI_GAME_AUTODISCOVER` | `KARNI_GAME_AUTODISCOVER` | `True` | import each app's `game.py` |
|
|
99
|
+
| `KARNI_GAME_ROLES` | `KARNI_GAME_ROLES` | `True` | declare the two roles |
|
|
100
|
+
|
|
101
|
+
## Security
|
|
102
|
+
|
|
103
|
+
- A player is found from the request only (the account, else the guest token). No endpoint takes a player's id from a client.
|
|
104
|
+
- A guest token is stored as its SHA-256 and revoked on upgrade.
|
|
105
|
+
- Balances change only through `karni_game.wallet.change` (row lock, conditional update, never below 0, capped).
|
|
106
|
+
- Portal callbacks and realtime reports are HMAC-SHA256 signed over a timestamp and the raw body, and refused past `KARNI_GAME_SIGNATURE_TOLERANCE`.
|
|
107
|
+
- Writes are rate limited per player, and a retry with the same `intent` never counts twice.
|
|
108
|
+
|
|
109
|
+
## Escape hatches
|
|
110
|
+
|
|
111
|
+
`KARNI_GAME_MERGER`, `KARNI_GAME_DAILY_SEED`, a run check and a save migration per game in `<app>/game.py`, a verifier per portal, the views of `karni_game.api` (subclass and mount your own), and the service modules the views call. The guide lists each.
|
|
112
|
+
|
|
113
|
+
## Tests
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
cd modules/karni-game && python -m pytest
|
|
117
|
+
# the wallet under two requests at once, on PostgreSQL:
|
|
118
|
+
PYTHONPATH=../../.github/ci DATABASE_URL=postgres://... python -m pytest --ds=karni_postgres_settings tests/test_concurrency.py
|
|
119
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# karni-game
|
|
2
|
+
|
|
3
|
+
Games for Karni: guest players, cloud saves, leaderboards, a soft-currency wallet, daily content and achievements, with a realtime server contract.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/karni-game/) [](https://github.com/cbsshekhawat18-lab/karni/blob/main/LICENSE) [](https://cbsshekhawat18-lab.github.io/karni/game/)
|
|
6
|
+
|
|
7
|
+
The server side of a game, for any game a project hosts. The server decides every reward, every price and every balance: a client only reports and asks. It is **experimental**: its names may change in a minor release, with a CHANGELOG entry.
|
|
8
|
+
|
|
9
|
+
The guide is [docs/game.md](https://cbsshekhawat18-lab.github.io/karni/game/), and the HTTP contract a client, a realtime server and a portal code against is [docs/game-api.md](https://cbsshekhawat18-lab.github.io/karni/game-api/).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install karni-game # karni-game[commerce] for real-money items
|
|
15
|
+
karni add game
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
A player is a person of the people contract, so set it above the settings call, and mount the API once:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
# config/settings.py
|
|
22
|
+
KARNI_PEOPLE = True
|
|
23
|
+
|
|
24
|
+
# config/urls.py, before path("api/", include("karni.api.urls"))
|
|
25
|
+
path("api/game/", include("karni_game.urls")),
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then `make migrate`. `karni new "Block Hopper" --kind game` writes all of it, with a `games` app, the game in `content/game.yaml` and a page at `/game`.
|
|
29
|
+
|
|
30
|
+
## What it adds
|
|
31
|
+
|
|
32
|
+
| Part | What |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Players | `Player` on `people.Person`: a guest with a token the server issues, an account once its email is verified, an upgrade that keeps the guest's progress (`people.merge` with the module's merge hook). |
|
|
35
|
+
| Saves | `Save`: versioned JSON per player, game and slot, a server version counter (409 with the server's copy on a stale write), a size limit, save migrations per game. |
|
|
36
|
+
| Boards | `Board`, `Score`, `Best`: periods on the game's clock, plausible ranges, runs (seed and input log) kept for review, flagged runs, run checks. |
|
|
37
|
+
| Wallet | `Currency`, `Wallet`, `LedgerEntry`: atomic and capped, a ledger entry with a reason for every move. |
|
|
38
|
+
| Rewards and shop | `Reward`, `Claim`, `Item`, `Ownership`: rewards declared on the server (daily, ad with a signed portal callback, mission, achievement, match, staff), cosmetics owned and equipped, a shop in soft currency, real-money items as the karni-commerce kind `game_item`. |
|
|
39
|
+
| Daily | `Streak`: the server's date, a daily seed per game, streaks with a grace rule, a daily board. |
|
|
40
|
+
| Achievements | `Achievement`, `Mission`, `Progress`, `Unlock`, `Completion`: counters the game reports, unlocked and granted by the server. |
|
|
41
|
+
| Config | `ConfigValue`: remote config and feature flags with a rollout, in the one boot call. Analytics checked against the game's schema and published as `game.analytics.tracked`. |
|
|
42
|
+
| Multiplayer | `Match`: a short-lived HS256 player token for a realtime server of your own, and its signed results report. |
|
|
43
|
+
|
|
44
|
+
The admin ships explicit classes (`karni_game/admin.py`) for players, scores, wallets and the ledger, where staff act. The other models use the derived admin. Two roles come with it (`game-manager`, `game-moderator`, the `karni.roles` entry point).
|
|
45
|
+
|
|
46
|
+
## Settings
|
|
47
|
+
|
|
48
|
+
| Setting | Env var | Default | Meaning |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| `KARNI_GAME_RATES` | | the defaults of docs/game-api.md | rates of the limited writes, by scope (`None` turns one off) |
|
|
51
|
+
| `KARNI_GAME_TOKEN_HEADER` | `KARNI_GAME_TOKEN_HEADER` | `X-Player-Token` | the guest token's header |
|
|
52
|
+
| `KARNI_GAME_CORS_ORIGINS` | `KARNI_GAME_CORS_ORIGINS` | `[]` | origins a portal build calls `/api/game/` from (tokens only) |
|
|
53
|
+
| `KARNI_GAME_SERVER_SECRET` | `KARNI_GAME_SERVER_SECRET` | blank | the realtime server's shared secret (at least 32 bytes). Blank: no multiplayer |
|
|
54
|
+
| `KARNI_GAME_TOKEN_ISSUER` | `KARNI_GAME_TOKEN_ISSUER` | `karni-game` | the player token's `iss` |
|
|
55
|
+
| `KARNI_GAME_TOKEN_SECONDS` | `KARNI_GAME_TOKEN_SECONDS` | `300` | the player token's life |
|
|
56
|
+
| `KARNI_GAME_PORTALS` | | `{}` | portals that call back after an ad: `{name: {"secret", "verifier"}}` |
|
|
57
|
+
| `KARNI_GAME_SIGNATURE_TOLERANCE` | `KARNI_GAME_SIGNATURE_TOLERANCE` | `300` | seconds a signed request's timestamp may be off |
|
|
58
|
+
| `KARNI_GAME_AD_INTENT_SECONDS` | `KARNI_GAME_AD_INTENT_SECONDS` | `3600` | an ad reward intent's life |
|
|
59
|
+
| `KARNI_GAME_CLIENT_CLAIMS_PER_DAY` | `KARNI_GAME_CLIENT_CLAIMS_PER_DAY` | `5` | the cap of a client-claimed ad reward |
|
|
60
|
+
| `KARNI_GAME_INTENT_DAYS` | `KARNI_GAME_INTENT_DAYS` | `7` | days a retry key is kept |
|
|
61
|
+
| `KARNI_GAME_MAX_SAVE_BYTES` | `KARNI_GAME_MAX_SAVE_BYTES` | `1048576` | the largest save any game allows |
|
|
62
|
+
| `KARNI_GAME_MAX_RUN_BYTES` | `KARNI_GAME_MAX_RUN_BYTES` | `262144` | the largest run record |
|
|
63
|
+
| `KARNI_GAME_MERGER` | `KARNI_GAME_MERGER` | `karni_game.merge.Merger` | the merge rules of two players |
|
|
64
|
+
| `KARNI_GAME_DAILY_SEED` | `KARNI_GAME_DAILY_SEED` | `karni_game.daily.daily_seed` | `seed(game, day) -> int` |
|
|
65
|
+
| `KARNI_GAME_AUTODISCOVER` | `KARNI_GAME_AUTODISCOVER` | `True` | import each app's `game.py` |
|
|
66
|
+
| `KARNI_GAME_ROLES` | `KARNI_GAME_ROLES` | `True` | declare the two roles |
|
|
67
|
+
|
|
68
|
+
## Security
|
|
69
|
+
|
|
70
|
+
- A player is found from the request only (the account, else the guest token). No endpoint takes a player's id from a client.
|
|
71
|
+
- A guest token is stored as its SHA-256 and revoked on upgrade.
|
|
72
|
+
- Balances change only through `karni_game.wallet.change` (row lock, conditional update, never below 0, capped).
|
|
73
|
+
- Portal callbacks and realtime reports are HMAC-SHA256 signed over a timestamp and the raw body, and refused past `KARNI_GAME_SIGNATURE_TOLERANCE`.
|
|
74
|
+
- Writes are rate limited per player, and a retry with the same `intent` never counts twice.
|
|
75
|
+
|
|
76
|
+
## Escape hatches
|
|
77
|
+
|
|
78
|
+
`KARNI_GAME_MERGER`, `KARNI_GAME_DAILY_SEED`, a run check and a save migration per game in `<app>/game.py`, a verifier per portal, the views of `karni_game.api` (subclass and mount your own), and the service modules the views call. The guide lists each.
|
|
79
|
+
|
|
80
|
+
## Tests
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd modules/karni-game && python -m pytest
|
|
84
|
+
# the wallet under two requests at once, on PostgreSQL:
|
|
85
|
+
PYTHONPATH=../../.github/ci DATABASE_URL=postgres://... python -m pytest --ds=karni_postgres_settings tests/test_concurrency.py
|
|
86
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Games (karni-game)
|
|
2
|
+
- The server side of a game: `path("api/game/", include("karni_game.urls"))` before the
|
|
3
|
+
API include, `KARNI_PEOPLE = True`. The client's contract is docs/game-api.md.
|
|
4
|
+
- Never write a player, save, score, wallet, ledger or achievement model of your own. A
|
|
5
|
+
player is `Player.person` (karni.people). Find it from the request, never from an id.
|
|
6
|
+
- The server decides: never accept coins, XP, an unlock or a price from a client. A balance
|
|
7
|
+
moves only through `karni_game.wallet.change` (atomic, capped, a ledger entry).
|
|
8
|
+
- Declare the game, its boards (`min_value`/`max_value` is the plausible range), currencies,
|
|
9
|
+
rewards, items, achievements and missions in `content/game.yaml` (`karni load`).
|
|
10
|
+
- Save migrations and run checks go in `<app>/game.py` (`@hooks.save_migration`,
|
|
11
|
+
`@hooks.run_check`). React to the game with its family events (`game.*`).
|
|
12
|
+
- A realtime server is your own service: it verifies the HS256 player token with
|
|
13
|
+
`KARNI_GAME_SERVER_SECRET` and posts signed results to `<game>/multiplayer/results/`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""karni-game (experimental): the server side of a game, for any game a project hosts.
|
|
2
|
+
|
|
3
|
+
A game's player is a person of the people contract (:mod:`karni.people`): a
|
|
4
|
+
guest first, with a token the server issues, then an account, keeping the
|
|
5
|
+
guest's progress. Each game (:class:`~karni_game.models.Game`) has versioned
|
|
6
|
+
cloud saves, leaderboards with plausible ranges, a soft-currency wallet with
|
|
7
|
+
a ledger, daily content on the server's date, achievements and missions,
|
|
8
|
+
remote config and feature flags, analytics through the family events, and a
|
|
9
|
+
contract for a realtime server of the project's own. The server decides
|
|
10
|
+
every reward and every balance: a client only reports and asks.
|
|
11
|
+
|
|
12
|
+
The client's HTTP contract is docs/game-api.md. Project code talks to the
|
|
13
|
+
service modules (:mod:`karni_game.players`, :mod:`karni_game.saves`,
|
|
14
|
+
:mod:`karni_game.scores`, :mod:`karni_game.wallet`, ...).
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from importlib import metadata as _metadata
|
|
20
|
+
|
|
21
|
+
#: The version of the game contract (the HTTP API of docs/game-api.md, the hooks of
|
|
22
|
+
#: :mod:`karni_game.hooks` and the family events of :mod:`karni_game.events`).
|
|
23
|
+
#: Experimental.
|
|
24
|
+
CONTRACT = 1
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
__version__ = _metadata.version("karni-game") # [project] version in pyproject.toml
|
|
28
|
+
except _metadata.PackageNotFoundError: # a source tree on sys.path, never installed
|
|
29
|
+
__version__ = "0+unknown"
|