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    /// Migrate Barracks from legacy layout (SlotCache 24B) to new layout (SlotCache 32B with dine_count).
48    MigrateBarracks = 42,
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/// Level up: increase level of seated shogun. Burns shards.
146#[repr(C)]
147#[derive(Clone, Copy, Debug, Pod, Zeroable)]
148pub struct LevelUpShogun {
149    pub slot: [u8; 8],
150}
151
152#[repr(C)]
153#[derive(Clone, Copy, Debug, Pod, Zeroable)]
154pub struct ClaimShards {} // Amount computed on-chain from ore; no client input (security).
155
156#[repr(C)]
157#[derive(Clone, Copy, Debug, Pod, Zeroable)]
158pub struct ClaimReferralReward {}
159
160#[repr(C)]
161#[derive(Clone, Copy, Debug, Pod, Zeroable)]
162pub struct ClaimRecruitReward {}
163
164#[repr(C)]
165#[derive(Clone, Copy, Debug, Pod, Zeroable)]
166pub struct ClaimForgeReward {}
167
168#[repr(C)]
169#[derive(Clone, Copy, Debug, Pod, Zeroable)]
170pub struct ClaimDineReward {}
171
172#[repr(C)]
173#[derive(Clone, Copy, Debug, Pod, Zeroable)]
174pub struct ClaimDailyReward {
175    pub signature: [u8; 64],
176}
177
178#[repr(C)]
179#[derive(Clone, Copy, Debug, Pod, Zeroable)]
180pub struct ClaimCollectionReward {
181    /// element×5 + rarity (0–24). Program finds 3 matching shoguns in pool.
182    pub collection_index: u8,
183}
184
185#[repr(C)]
186#[derive(Clone, Copy, Debug, Pod, Zeroable)]
187pub struct BuyBundle {} // Fixed bundle: TICKET_BUNDLE_SOL for TICKET_BUNDLE_TICKETS
188
189#[repr(C)]
190#[derive(Clone, Copy, Debug, Pod, Zeroable)]
191pub struct BuyTicketsWithShards {} // Fixed: 5 tickets for 300 shards (daily deal)
192
193#[repr(C)]
194#[derive(Clone, Copy, Debug, Pod, Zeroable)]
195pub struct BuyFlashSale {} // Flash sale: 50 tickets for 5000 shards, max 5/day
196
197#[repr(C)]
198#[derive(Clone, Copy, Debug, Pod, Zeroable)]
199pub struct ClearForgeCooldown {}
200
201#[repr(C)]
202#[derive(Clone, Copy, Debug, Pod, Zeroable)]
203pub struct SetGenesisSlot {
204    pub genesis_slot: [u8; 8],
205    /// Slots per halving period. 0 = use HALVING_PERIOD_SLOTS_DEFAULT (~58 days, matches Hyper Ninja).
206    pub halving_period_slots: [u8; 8],
207}
208
209#[repr(C)]
210#[derive(Clone, Copy, Debug, Pod, Zeroable)]
211pub struct Log {
212    pub _reserved: [u8; 8], // Variable-length log; remaining bytes are message
213}
214
215#[repr(C)]
216#[derive(Clone, Copy, Debug, Pod, Zeroable)]
217pub struct RollSceneSectionAmethyst {
218    pub count: [u8; 8],   // 1 or 10
219    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
220}
221
222#[repr(C)]
223#[derive(Clone, Copy, Debug, Pod, Zeroable)]
224pub struct RollSceneSectionShards {
225    pub count: [u8; 8],   // 1 or 10
226    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
227}
228
229/// Salvage all duplicate scene sections for Amethyst refund. Program derives from on-chain state.
230#[repr(C)]
231#[derive(Clone, Copy, Debug, Pod, Zeroable)]
232pub struct SalvageSceneSection {}
233
234#[repr(C)]
235#[derive(Clone, Copy, Debug, Pod, Zeroable)]
236pub struct BuyChest {}
237
238#[repr(C)]
239#[derive(Clone, Copy, Debug, Pod, Zeroable)]
240pub struct BuyScene {
241    pub scene_id: [u8; 8], // 6, 7, or 8
242}
243
244#[repr(C)]
245#[derive(Clone, Copy, Debug, Pod, Zeroable)]
246pub struct UpdateActiveScene {
247    pub scene_id: [u8; 8],
248}
249
250/// Buy scene (6/7/8) with mixed payment: spend all amethyst, cover shortfall with DOJO.
251#[repr(C)]
252#[derive(Clone, Copy, Debug, Pod, Zeroable)]
253pub struct BuySceneDojo {
254    pub scene_id: [u8; 8],
255}
256
257#[repr(C)]
258#[derive(Clone, Copy, Debug, Pod, Zeroable)]
259pub struct MigrateBarracks {}
260
261instruction!(DojosInstruction, Initialize);
262instruction!(DojosInstruction, BuyStarterPack);
263instruction!(DojosInstruction, RecruitShogunTickets);
264instruction!(DojosInstruction, RecruitShogunSol);
265instruction!(DojosInstruction, SeatShogun);
266instruction!(DojosInstruction, SeatShogunFillAll);
267instruction!(DojosInstruction, ReplaceShogun);
268instruction!(DojosInstruction, Dine);
269instruction!(DojosInstruction, UpgradeBarracksShards);
270instruction!(DojosInstruction, UpgradeBarracksSol);
271instruction!(DojosInstruction, UpgradeForge);
272instruction!(DojosInstruction, MergeShogun);
273instruction!(DojosInstruction, PrestigeUpgrade);
274instruction!(DojosInstruction, ClaimShards);
275instruction!(DojosInstruction, ClaimReferralReward);
276instruction!(DojosInstruction, ClaimRecruitReward);
277instruction!(DojosInstruction, ClaimForgeReward);
278instruction!(DojosInstruction, ClaimDineReward);
279instruction!(DojosInstruction, ClaimDailyReward);
280instruction!(DojosInstruction, ClaimCollectionReward);
281instruction!(DojosInstruction, BuyBundle);
282instruction!(DojosInstruction, BuyTicketsWithShards);
283instruction!(DojosInstruction, BuyFlashSale);
284instruction!(DojosInstruction, ClearForgeCooldown);
285instruction!(DojosInstruction, SetGenesisSlot);
286instruction!(DojosInstruction, Log);
287instruction!(DojosInstruction, LevelUpShogun);
288instruction!(DojosInstruction, RollSceneSectionAmethyst);
289instruction!(DojosInstruction, RollSceneSectionShards);
290instruction!(DojosInstruction, SalvageSceneSection);
291instruction!(DojosInstruction, BuyChest);
292instruction!(DojosInstruction, BuyScene);
293instruction!(DojosInstruction, UpdateActiveScene);
294instruction!(DojosInstruction, BuySceneDojo);
295instruction!(DojosInstruction, MigrateBarracks);