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