helheimlabs / autochessia Goto Github PK
View Code? Open in Web Editor NEWFully on-chain auto chess, built with MUD
Home Page: https://dev.autochessia.xyz
License: GNU Affero General Public License v3.0
Fully on-chain auto chess, built with MUD
Home Page: https://dev.autochessia.xyz
License: GNU Affero General Public License v3.0
@ClaudeZsb
For the code below. Can we surrender when GameStatus
is INBATTLE
. Is there any side effect.
New UI is good, but it miss some info.
It has something mismatch
For better UX
Allows spectating via URL, in-game player spectating
Lobby music
Purchase music
Preparation music
Combat music
Victory music
Defeat music
Two propositions
We're going to implement this feature through the first way, which will enrich our experience of zk development.
Prerequisite. This feature requires that More gas efficient is resolved.
What we want to have is that when a player has a certain number of heroes of the same race, it will give a specific effect to all his heroes. And this mechanism can give birth to a variety of hero combinations.
Creature: {
keySchema: {
index: "uint16",
},
schema: {
race: "uint32",
health: "uint32",
attack: "uint32",
range: "uint32",
defense: "uint32",
speed: "uint32",
movement: "uint32",
},
},
race
is an uint32 and is composited by 8 numbers of length 4 bits. Each number of length 4 bits represents one race and its position within race
is fixed.
race | race_1 | race_2-7 | race_8 |
---|---|---|---|
length | 4 bits | 24 bits | 4 bits |
race_*
= 0000
or 0001
. 0001
represents this creature belongs to race_*
PvE is better to have. Some personal thinking:
To make it a rougue-like autochess, there would be at least:
PvELevel
where enemy lineup, reward of each level are stored.PvESystem
that serves PvE process control, random map generating, random reward generating etc.Challenges
Creature: {
keySchema: {
index: "uint32",
},
schema: {
health: "uint32",
attack: "uint32",
range: "uint32",
defense: "uint32",
speed: "uint32",
movement: "uint32",
uri: "string",
},
},
CreatureConfig: {
keySchema: {
index: "uint32",
},
schema: {
healthAmplifier: "uint16[]", // decimal 2 // example: [210,330]
attackAmplifier: "uint16[]", // decimal 2
defenseAmplifier: "uint16[]", // decimal 2
},
},
This is how we do now:
Creature
table. This costs 1 slot
. (despite of Creature.uri
)
Here,
1 slot
means the gas required for reading abytes32
from evm.
CreatureConfig
table.
Creature.health
, Creature.attack
and Creature.defense
.uint16
.3 (slots) = 1 + 1 + 1
.So we spend 4 slots
in total for constructing a piece of tier 1/2. And it should be clear that this job is done at the first turn of each round. So since a Creature
can be packed tightly and stored in one slot, why not store any hero of tier 1/2 in the same way as hero of tier 0. Then we will save 3 slots
for every players in every round.
Obviously this optimization is feasible and quiet worth doing. Further more, we can integrate tier info into index of Creature
. One suggestion is: (max_tier=255
and max_creature_num=255
)
index | tier | internal_index |
---|---|---|
length | 8 bits | 8 bits |
Besides, Creature.uri
is not used in any game playing. And heroes with same creature index but different tier share the same uri
. So we can create a new table to only store uri
.
CreatureUri: {
keySchema: {
index: "uint8",
},
schema: {
uri: "string",
},
},
bad UX
. When you buy an hero in altar, the last unsold hero would move to the slot where the bought hero previously was. This is becase we technically implement a pop operation of an array through replacing the popped one by the last one.
bad UX
. The same issue of hero inventory as the previous one.bad UX
. Sometimes, it takes a long time for loading hero images. @noyyyyfront-end bug
. When you have more than 1 hero on your board, all replacing operations of an hero on board only apply to the last one you put on board. @aLIEzsss4contract bug
. Once there were 3 Juggs of the same tier, but they were not merged. When the 4th Jugg was bought, 2 of 3 Juggs did merged with the bought one. @ClaudeZsbmud indexer bug
. A while after starting a game, values of tables were not synced and updated. @noyyyycontract bug
. In the case of 3 players, sometimes two players had the same other player as their opponent. @ClaudeZsbLooks like a quick play button that will only focus the player population into one room for a period of time. Can be extended to ladder point matchmaking.
In addition, for a better multiplayer online UX, should we add a confirm match button similar to Dota 2 accept button, where not accepting could incur penalties?
PlayerGlobal: {
keySchema: {
addr: "address",
},
schema: {
roomId: "bytes32",
gameId: "uint32",
status: "PlayerStatus",
},
},
First of all, roomId
is reusable. Then a field of 2**256
seems to be too large and produces waste of storage. PlayerGlobal
can be limited into just one slot if we use uint128
instead. Then any read or write of this table could be more gas efficient.
In order to realize more complex battle system that supports skills, buffs and debuffs.
Future features like hero abilities, equipment, racial effects would heavily rely on this.
It's a repetitive work to deploy latest contract to testnet. It saves time if we have a cron job to deploy newest contract every night.
related to #87 (review)
Current preview is not the latest pr commit
contract bug
. Sell a non-exist hero in inventory.contract bug
. Coin income is too high.contract bug
. A new bought hero overwrites the hero in the first slot of inventory. This causes the loss of an hero.contract bug
. Revert during tick.bad UX
. Countdown is too fast.front-end bug
. Service of automatic ticking is not stable.Now, we use getUniqueEntity
to generate key when place a hero to board. It's unpredictable and not deterministic. So we can not use optimistic rendering.
I suggest use the following pattern to generate hero key
keccak256(abi.encode(userAddress, gameId, orderOfHeroOnboard))
Accordingly, we need to delete data in table Hero
when place piece back to inventory.
@aLIEzsss4
The autobattle runs on blocknumber increase, it's can lead to excessive rpc call if the block number increase fastly.
autochessia/packages/client/src/hooks/useBlockNumber.ts
Lines 23 to 58 in cee1c57
The better way is to run the next autobattle only when the previous one is confirmed on chain. In this way, the front end will have a balanced rpc call requence.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.