-
Notifications
You must be signed in to change notification settings - Fork 8
/
eoscrazytown.hpp
130 lines (107 loc) · 3.75 KB
/
eoscrazytown.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* @dev minakokojima, yukiexe
* @copyright Andoromeda
*/
#pragma once
#include <eosiolib/eosio.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/singleton.hpp>
// #include <cmath>
// #include <string>
#include "config.hpp"
#include "utils.hpp"
// #include "eosio.token.hpp"
#define EOS_SYMBOL eosio::symbol("EOS", 4)
#define TOKEN_CONTRACT "eosio.token"_n
typedef double real_type;
typedef uint8_t card ;
using namespace std;
using namespace eosio;
CONTRACT eoscrazytown : public eosio::contract {
public:
eoscrazytown( name receiver, name code, datastream<const char*> ds ) :
contract(receiver, code, ds),
_global(receiver, receiver.value),
_players(receiver, receiver.value) {}
<<<<<<< HEAD
=======
>>>>>>> e674a5b58ceeea666c4a0c0358641ec476e33ada
ACTION init(const capi_checksum256& hash);
ACTION clear();
// ACTION test();
// ACTION verify( const capi_checksum256& seed, const capi_checksum256& hash );
ACTION reveal(const capi_checksum256& seed, const capi_checksum256& hash);
<<<<<<< HEAD
ACTION transfer(name from,
name to,
asset quantity,
string memo);
=======
>>>>>>> e674a5b58ceeea666c4a0c0358641ec476e33ada
// rec
ACTION receipt(const rec_reveal& reveal) {
require_auth(get_self());
}
struct [[eosio::table("global")]] st_global {
uint64_t defer_id = 0;
capi_checksum256 hash;
<<<<<<< HEAD
};
typedef singleton<"global"_n, st_global> singleton_global;
singleton_global _global;
=======
uint8_t dragon ;
uint8_t tiger ;
};
>>>>>>> e674a5b58ceeea666c4a0c0358641ec476e33ada
TABLE player {
uint64_t account; //account_name to uint64
vector<int64_t> vbets ;
auto primary_key() const { return account; }
EOSLIB_SERIALIZE(player, (account)(vbets))
};
typedef singleton<"global"_n, st_global> singleton_global;
typedef eosio::multi_index<"player"_n, player> player_t;
singleton_global _global ;
player_t _players;
<<<<<<< HEAD
void apply(uint64_t receiver, uint64_t code, uint64_t action) ;
=======
void apply(uint64_t receiver, uint64_t code, uint64_t action);
>>>>>>> e674a5b58ceeea666c4a0c0358641ec476e33ada
private:
void onTransfer(name &from,
name &to,
asset &quantity,
string &memo);
const vector<int64_t> getBets(const string &s, const char &c) ;
auto getBeton( const vector<int64_t> &v );
const int64_t getTotalBets(const vector<int64_t> &v);
const auto checkBets( const asset &eos, const string &memo,
vector<int64_t> &vbets, int64_t &totalBets );
auto getResult( const card &a, const card &b ) ;
};
void eoscrazytown::apply(uint64_t receiver, uint64_t code, uint64_t action) {
auto &thiscontract = *this;
if (action == ( "transfer"_n ).value && code == ( "eosio.token"_n ).value ) {
auto transfer_data = unpack_action_data<st_transfer>();
onTransfer(transfer_data.from, transfer_data.to, transfer_data.quantity, transfer_data.memo);
return;
}
if (code != get_self().value) return;
switch (action) {
EOSIO_DISPATCH_HELPER(eoscrazytown,
(init)
(clear)
(reveal)
(receipt)
);
};
}
extern "C" {
[[noreturn]] void apply(uint64_t receiver, uint64_t code, uint64_t action) {
eoscrazytown p( name(receiver), name(code), datastream<const char*>(nullptr, 0) );
p.apply(receiver, code, action);
eosio_exit(0);
}
}