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