Skip to main content

tengu_api/
instruction.rs

1//! Instruction enum and data structs.
2
3use steel::*;
4
5#[repr(u8)]
6#[derive(Clone, Copy, Debug, Eq, PartialEq, num_enum::TryFromPrimitive)]
7pub enum DojosInstruction {
8    // Init
9    BuyStarterPack = 1,
10
11    // Player
12    RecruitShogunTickets = 2,
13    RecruitShogunSol = 32,
14    SeatShogun = 3,
15    SeatShogunFillAll = 41,
16    ReplaceShogun = 34,
17    Dine = 5,
18    UpgradeBarracksShards = 7,
19    UpgradeBarracksSol = 26,
20    UpgradeForge = 8,
21    MergeShogun = 9,
22    PrestigeUpgrade = 10,
23    ClaimShards = 11,
24    ClaimReferralReward = 12,
25    ClaimRecruitReward = 36,
26    ClaimForgeReward = 37,
27    ClaimDineReward = 38,
28    ClaimDailyReward = 39,
29    ClaimCollectionReward = 40,
30    BuyBundle = 13,
31    BuyTicketsWithShards = 22,
32    BuyFlashSale = 24,
33    ClearForgeCooldown = 15,
34    Log = 20,
35    LevelUpShogun = 25,
36    RollSceneSectionAmethyst = 27,
37    RollSceneSectionShards = 31,
38    SalvageSceneSection = 28,
39    BuyChest = 29,
40    BuyScene = 33,
41    UpdateActiveScene = 30,
42    BuySceneDojo = 35,
43
44    // Admin
45    Initialize = 0,
46    SetGenesisSlot = 19,
47
48    // Migration
49    MigrateDojo = 42,
50}
51
52#[repr(C)]
53#[derive(Clone, Copy, Debug, Pod, Zeroable)]
54pub struct Initialize {}
55
56#[repr(C)]
57#[derive(Clone, Copy, Debug, Pod, Zeroable)]
58pub struct BuyStarterPack {
59    pub referrer: [u8; 32], // Option<Pubkey> as bytes; [0u8;32] = None
60}
61
62#[repr(C)]
63#[derive(Clone, Copy, Debug, Pod, Zeroable)]
64pub struct RecruitShogunTickets {
65    pub count: [u8; 8],   // 1 or 10
66    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
67}
68
69#[repr(C)]
70#[derive(Clone, Copy, Debug, Pod, Zeroable)]
71pub struct RecruitShogunSol {
72    pub count: [u8; 8],   // 1 or 10
73    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
74}
75
76/// Seat: promote one from fodder to barracks slot. rarity 0-4, element 0-4.
77#[repr(C)]
78#[derive(Clone, Copy, Debug, Pod, Zeroable)]
79pub struct SeatShogun {
80    pub slot: [u8; 8],
81    pub rarity: [u8; 8],
82    pub element: [u8; 8],
83}
84
85/// Per-seat entry for fill-all. Promotes from fodder to first empty slot.
86#[repr(C)]
87#[derive(Clone, Copy, Debug, Pod, Zeroable)]
88pub struct SeatShogunFillAllEntry {
89    pub rarity: [u8; 8],
90    pub element: [u8; 8],
91}
92
93/// Batch seat: up to 12 shoguns into empty slots. Slots inferred: first empty, second empty, ...
94#[repr(C)]
95#[derive(Clone, Copy, Debug, Pod, Zeroable)]
96pub struct SeatShogunFillAll {
97    pub count: u8,
98    pub _pad: [u8; 7],
99    pub entries: [SeatShogunFillAllEntry; 12],
100}
101
102/// Replace: return old to fodder, promote new from fodder. Same slot.
103#[repr(C)]
104#[derive(Clone, Copy, Debug, Pod, Zeroable)]
105pub struct ReplaceShogun {
106    pub slot: [u8; 8],
107    pub new_rarity: [u8; 8],
108    pub new_element: [u8; 8],
109}
110
111/// Dine: restore chakra for seated shogun. tier 0=24h, 1=48h, 2=72h.
112#[repr(C)]
113#[derive(Clone, Copy, Debug, Pod, Zeroable)]
114pub struct Dine {
115    pub tier: [u8; 8],
116    pub slot: [u8; 8],
117}
118
119#[repr(C)]
120#[derive(Clone, Copy, Debug, Pod, Zeroable)]
121pub struct UpgradeBarracksShards {}
122
123#[repr(C)]
124#[derive(Clone, Copy, Debug, Pod, Zeroable)]
125pub struct UpgradeBarracksSol {}
126
127#[repr(C)]
128#[derive(Clone, Copy, Debug, Pod, Zeroable)]
129pub struct UpgradeForge {}
130
131/// Merge: consume from fodder_counts, add new. seed from BSM /merge.
132#[repr(C)]
133#[derive(Clone, Copy, Debug, Pod, Zeroable)]
134pub struct MergeShogun {
135    pub merge_type: [u8; 8], // 0=10×N, 1=5×R, 2=3×SR
136    pub seed: [u8; 32],
137}
138
139/// Prestige: consume 2 from fodder_counts[rarity], upgrade seated shogun in slot.
140#[repr(C)]
141#[derive(Clone, Copy, Debug, Pod, Zeroable)]
142pub struct PrestigeUpgrade {
143    pub slot: [u8; 8],
144}
145
146/// Level up: increase level of seated shogun. Burns shards.
147#[repr(C)]
148#[derive(Clone, Copy, Debug, Pod, Zeroable)]
149pub struct LevelUpShogun {
150    pub slot: [u8; 8],
151}
152
153#[repr(C)]
154#[derive(Clone, Copy, Debug, Pod, Zeroable)]
155pub struct ClaimShards {} // Amount computed on-chain from ore; no client input (security).
156
157#[repr(C)]
158#[derive(Clone, Copy, Debug, Pod, Zeroable)]
159pub struct ClaimReferralReward {}
160
161#[repr(C)]
162#[derive(Clone, Copy, Debug, Pod, Zeroable)]
163pub struct ClaimRecruitReward {}
164
165#[repr(C)]
166#[derive(Clone, Copy, Debug, Pod, Zeroable)]
167pub struct ClaimForgeReward {}
168
169#[repr(C)]
170#[derive(Clone, Copy, Debug, Pod, Zeroable)]
171pub struct ClaimDineReward {}
172
173#[repr(C)]
174#[derive(Clone, Copy, Debug, Pod, Zeroable)]
175pub struct ClaimDailyReward {
176    pub signature: [u8; 64],
177}
178
179#[repr(C)]
180#[derive(Clone, Copy, Debug, Pod, Zeroable)]
181pub struct ClaimCollectionReward {
182    /// element×5 + rarity (0–24). Program finds 3 matching shoguns in pool.
183    pub collection_index: u8,
184}
185
186#[repr(C)]
187#[derive(Clone, Copy, Debug, Pod, Zeroable)]
188pub struct BuyBundle {} // Fixed bundle: TICKET_BUNDLE_SOL for TICKET_BUNDLE_TICKETS
189
190#[repr(C)]
191#[derive(Clone, Copy, Debug, Pod, Zeroable)]
192pub struct BuyTicketsWithShards {} // Fixed: 5 tickets for 300 shards (daily deal)
193
194#[repr(C)]
195#[derive(Clone, Copy, Debug, Pod, Zeroable)]
196pub struct BuyFlashSale {} // Flash sale: 50 tickets for 5000 shards, max 5/day
197
198#[repr(C)]
199#[derive(Clone, Copy, Debug, Pod, Zeroable)]
200pub struct ClearForgeCooldown {}
201
202#[repr(C)]
203#[derive(Clone, Copy, Debug, Pod, Zeroable)]
204pub struct SetGenesisSlot {
205    pub genesis_slot: [u8; 8],
206    /// Slots per halving period. 0 = use HALVING_PERIOD_SLOTS_DEFAULT (~58 days, matches Hyper Ninja).
207    pub halving_period_slots: [u8; 8],
208}
209
210#[repr(C)]
211#[derive(Clone, Copy, Debug, Pod, Zeroable)]
212pub struct Log {
213    pub _reserved: [u8; 8], // Variable-length log; remaining bytes are message
214}
215
216#[repr(C)]
217#[derive(Clone, Copy, Debug, Pod, Zeroable)]
218pub struct RollSceneSectionAmethyst {
219    pub count: [u8; 8],   // 1 or 10
220    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
221}
222
223#[repr(C)]
224#[derive(Clone, Copy, Debug, Pod, Zeroable)]
225pub struct RollSceneSectionShards {
226    pub count: [u8; 8],   // 1 or 10
227    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
228}
229
230/// Single salvage entry: (scene_id, section_id) + count to salvage.
231/// scene_id: 0–8, section_id: 0–11, count: 1–65535.
232#[repr(C)]
233#[derive(Clone, Copy, Debug, Pod, Zeroable)]
234pub struct SalvageItem {
235    pub scene_id: u8,
236    pub section_id: u8,
237    pub count: u16,
238}
239
240/// Salvage duplicate scene sections for Amethyst refund. Single ix handles any amount.
241/// item_count: number of valid entries in items (1–64).
242#[repr(C)]
243#[derive(Clone, Copy, Debug, Pod, Zeroable)]
244pub struct SalvageSceneSection {
245    pub item_count: u8,
246    pub _pad: [u8; 3],
247    pub items: [SalvageItem; 64],
248}
249
250#[repr(C)]
251#[derive(Clone, Copy, Debug, Pod, Zeroable)]
252pub struct BuyChest {}
253
254#[repr(C)]
255#[derive(Clone, Copy, Debug, Pod, Zeroable)]
256pub struct BuyScene {
257    pub scene_id: [u8; 8], // 6, 7, or 8
258}
259
260#[repr(C)]
261#[derive(Clone, Copy, Debug, Pod, Zeroable)]
262pub struct UpdateActiveScene {
263    pub scene_id: [u8; 8],
264}
265
266/// Buy scene (6/7/8) with mixed payment: spend all amethyst, cover shortfall with DOJO.
267#[repr(C)]
268#[derive(Clone, Copy, Debug, Pod, Zeroable)]
269pub struct BuySceneDojo {
270    pub scene_id: [u8; 8],
271}
272
273/// Migrate Dojo: expand fodder_counts from [5] to [25] (element×5+rarity).
274#[repr(C)]
275#[derive(Clone, Copy, Debug, Pod, Zeroable)]
276pub struct MigrateDojo {}
277
278instruction!(DojosInstruction, Initialize);
279instruction!(DojosInstruction, BuyStarterPack);
280instruction!(DojosInstruction, RecruitShogunTickets);
281instruction!(DojosInstruction, RecruitShogunSol);
282instruction!(DojosInstruction, SeatShogun);
283instruction!(DojosInstruction, SeatShogunFillAll);
284instruction!(DojosInstruction, ReplaceShogun);
285instruction!(DojosInstruction, Dine);
286instruction!(DojosInstruction, UpgradeBarracksShards);
287instruction!(DojosInstruction, UpgradeBarracksSol);
288instruction!(DojosInstruction, UpgradeForge);
289instruction!(DojosInstruction, MergeShogun);
290instruction!(DojosInstruction, PrestigeUpgrade);
291instruction!(DojosInstruction, ClaimShards);
292instruction!(DojosInstruction, ClaimReferralReward);
293instruction!(DojosInstruction, ClaimRecruitReward);
294instruction!(DojosInstruction, ClaimForgeReward);
295instruction!(DojosInstruction, ClaimDineReward);
296instruction!(DojosInstruction, ClaimDailyReward);
297instruction!(DojosInstruction, ClaimCollectionReward);
298instruction!(DojosInstruction, BuyBundle);
299instruction!(DojosInstruction, BuyTicketsWithShards);
300instruction!(DojosInstruction, BuyFlashSale);
301instruction!(DojosInstruction, ClearForgeCooldown);
302instruction!(DojosInstruction, SetGenesisSlot);
303instruction!(DojosInstruction, Log);
304instruction!(DojosInstruction, LevelUpShogun);
305instruction!(DojosInstruction, RollSceneSectionAmethyst);
306instruction!(DojosInstruction, RollSceneSectionShards);
307instruction!(DojosInstruction, SalvageSceneSection);
308instruction!(DojosInstruction, BuyChest);
309instruction!(DojosInstruction, BuyScene);
310instruction!(DojosInstruction, UpdateActiveScene);
311instruction!(DojosInstruction, BuySceneDojo);
312instruction!(DojosInstruction, MigrateDojo);