-
Notifications
You must be signed in to change notification settings - Fork 0
/
monsterWar.sol
67 lines (55 loc) · 1.64 KB
/
monsterWar.sol
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
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
//contact : [email protected]
//crypto wallet : Fettah@crypto
/*
simple game I (fettah) created
there is MosterChest that gives you one of three common monsters with radom attributes .
contract creator can decide what is the cost of the chest is then any one can buy chests for ETH
user then can open the chest they have to get one of 3 monsters .
you can merge 2 monsters to get higher level stronger moster
you send your monster to war by adding eth
monsters in war get matched randomly and the winner take 90% of the loser eth the remaining 10% sent to the contract creator
*/
contract MosterWar{
// the admin
address admin;
// chest data
struct Chest{
uint price;
mapping (address => uint) owned;
}
Chest chest;
//monster data
enum element{ fire , water , earth }
enum rarity{ common , rare , epic , legend }
struct Stats{
uint ATK;
uint DEF;
uint HP;
element Element;
rarity Rarity;
}
struct monster{
uint ID;
Stats stats;
}
constructor(uint _price){
chest.price = _price;
admin = msg.sender;
}
function buyChest() payable public{
require(msg.value == chest.price ,"you need to send the chest price");
payable(admin).transfer(msg.value);
++chest.owned[msg.sender];
}
/*
function openChest(){
//todo not finished yet ...
}
function SendToWar(){
//todo not finished yet ...
}
//todo not finished yet ...
*/
}