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