GithubHelp home page GithubHelp logo

cryptoblades's Introduction

CryptoBlades

Warning

This code is open, but not open source. It is not licensed, which means you cannot use it freely for your own applications. You cannot "base your code on CryptoBlades", nor use our code for anything. At all. This is not permissible under our license terms (which do not exist).

Currency Setup

  1. Install Ganache.
  2. For Ganache, choose Quickstart Ethereum.
  3. Increase the gas limit in the workspace to 99999999 (or some other high number so you can deploy).
  4. Install MetaMask.
  5. Create a new connection to connect to Ganache with these settings: http://localhost:7545, any name, any chain id
  6. In Ganache, click the key icon on the right side of any address and grab the private key. Make sure that chainID is 5777.
  7. In MetaMask, create a new account, import from private key, and paste the key in there.

You should now have 100 fake eth! You're now fake rich.

Frontend Setup

  1. npm install
  2. mv .env.local .env (copy the example env to your local so it can be used)
  3. npm run contract:prepare (this builds your contracts)
  4. npm run contract:deploy (this deploys your contracts to your local blockchain)
  5. npm run start:frontend

For Windows developers experiencing errors follow these steps:

  1. rm -r build
  2. npm run contract:prepare (this builds your contracts)
  3. rm -r build/contracts
  4. npm run contract:deploy
  5. npm run start:frontend

VSCode Setup

If you're using VSCode, we recommend these extensions: Auto Rename Tag, EditorConfig for VSCode, Eslint, Github Pull Requests, Gitlens, Javascript and Typescript, Live Share, Solidity, Typescript Hero, Vetur

Environment Variables

There are optional environment variables, most of which have sensible defaults if copied from .env.local:

  • VUE_APP_API_URL - the API URL to use - defaults to prod (which will throw CORS errors on local)

Structure

  • contracts contains the solidity contracts for the game
  • frontend contains the Vue code for the frontend
  • migrations contains migration files
  • test contains tests

Commands

  • npm run start:frontend - start up a server for the Vue frontend
  • npm run lint - run lint checking for all modules
  • npm run contract:prepare - extract the ABI and re-compile Truffle contracts
  • npm run contract:deploy - deploy the Truffle contracts for testing
  • npm run test:local - run tests via hardhat, careful, this is not using migrations but rather fixtures which should be kept up to date (/test/helpers/prepareContracts.js)

Errors

  • If you run into any error at all during the build process you may need to reset Ganache by deleting previous workspaces and going through the Ganache setup process again including importing a new account for Metamask.
  • Artifacts are from different compiler runs - rm -rf build/

Running tests locally

To run tests locally simply run

npm run test:local

NOTE: Careful, this is not using migrations but rather fixtures which should be kept up to date (/test/helpers/prepareContracts.js)

Config

  • All network config is in app-config.json
  • cd frontend - navigate to frontend folder
  • npm run setup-app-config -Initial setup of app-config.json file
  • If you want to add a new network: add it's configuration in app-config.json and add update currentTokenPrice getter in EarningsCalculator.

Alternative development flow with Hardhat

This repository uses Truffle, but if for some reason, you'd prefer using hardhat for development, with an ephemeral local blockchain, you can do so too:

Turn on the Hardhat node: npx hardhat node

Generate Hardhat artifacts: npx hardhat compile

Deploy to the Hardhat node: export ETH_DEV_RPC_PORT=8545 && npm run deploy --reset

Run the frontend pointing to hardhat: export VUE_APP_NETWORK_ID=31337 && npm run start:frontend

If you get any issues during deployment, run: truffle compile --all

i18n (Internationalization) - Adding strings for translation

  • We use vue-18n for internationalization
  • Fallback is English, if a string is not added or empty

Replacing strings in the code

  • Replace strings in template with {{$t('keyName')}}
  • Replace strings in script with i18n.t('keyName')
  • Pass objects/values with {{$t('keyName', someValue)}} and use it in en.json: "keyName": "This is {someValue} !"
  • You can use markdown by using v-html: <p v-html="$t('keyName'})"></p> with "keyName": "This is <b>bold</b>"
  • Avoid splitting up strings. If a sentences is split up, it can't be translated in some language properly. (example and docu)

Adding a new language

  • Add a new JSON file to ~/frontend/src/locales/ by copying en.json and renaming it to your language code. Use the 2-Letter ISO code of your language
  • Language is loaded on startup and added to the language drop-down of the Options page.
  • The value for the drop-down is "name" at the root of the json map.

i18n Manager App

  • Adding translations is easier with the use of i18n-manager
  • Download the app, install it on your device and run it.
  • Point it to the folder containing locale files. (frontend/src/locales)
  • Add translations, save with ctrl + s, you should be able to see changes immediately after rebuilding

Alt

cryptoblades's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptoblades's Issues

Claim flow

Claim should be moved to settings drop down

First promopt "Need Gas? Try our WAX Bridge, which will pay you .5% under market rate to sell your WAX for BNB!" Button to the wax bridge, button for Next

Next prompt,
"If you stake your SKILL now, we will give you a 10% bonus in SKILL that you can use in-game right away!" Button to stake page
Under that, just small text that is actually a link, "No thanks, I'd rather [pay x% in taxes and withdraw and] forfeit my bonus]" depending on if any of their funds are taxable (they may have waited 15 days thus no tax).
Next prompt
You are about to [ pay x% in Tax for early withdrawal costing you Y SKILL] forfeit all bonus SKILL earnings for 3 days costing you Z skill], are you sure you wish to continue? This action cannot be undone"

add extra confirmation for reforging in certain circumstances

the dialog should have a base "are you sure you want to reforge with this item" message.

if the item is 4/5*, it should add "this is a rare item"

if the item has any LBs, it should add "this item has been previously reforged and LBs will not carry over"

On the Blacksmith screen, expand to fill the full page during forging

Half of the browser width is allocated to selecting a weapon to burn for reforging. This UI is hidden until the Reforge button is clicked. While in that initial state, the reforging panel should be absent or zero width so that the entire browser width is available for displaying the grid of weapons being forged.

add google analytics events

  • click forge button
  • click reforge button
  • click recruit button
  • click combat button
  • page views for individual pages
  • click sell on market

an ideal solution would use document.on('click') to filter out all buttons so any button click is registered. might need additional work from there.

Duplicated Band Description

#77 introduced the "guaranteed" bands (loss/win), but duplicated the descriptor "Unlikely" for both <30 and 0. Either another descriptor should be chosen (EG: Impossible), or one of the return statements should be removed.

#BoredAtWork

allow quicker switching of characters

in the character bar, we have a lot of unused space.

on the far right side, we should have a short listing of characters, clicking them will make them active.

there should be no portrait, but it should be shown as a line like: Name Lv. XX

Revamp initial user experience (add a tutorial)

  • Brief intro graphic/steps on connecting metamask in case they somehow got here directly
  • Repeat of instructions on the above for BNB/SKILL
  • Take them to combat
  • Explain the breakdown of their earnings
  • Take them to the blacksmith
  • Explain the sword they have, reforge, and how creating new swords makes them stronger
  • Take them to the market to see how to see what other players are doing
  • Tell them to join our community in Discord or Telegram for further help and connect with other players
  • this needs analytics events to see how far people get in the process

this would likely use a "walkthrough" or "tour" module

Reentrancy attack vulnerabilities

The concept of this attack is to use a piece of logic responsible for e.g. sending tokens as many times as possible before the account balance is adjusted.

Vulnerable function in our contract:

function claimTokenRewards() public {
        // our characters go to the tavern
        // and the barkeep pays them for the bounties
        _payPlayerConverted(msg.sender, tokenRewards[msg.sender]);
        tokenRewards[msg.sender] = 0;
}

Obviously it's not possible to exploit it manually, but one could write a contract that imports our contract and calls claimTokenRewards() in a loop. That could lead to them claiming the rewards multiple times before their balance is adjusted to 0.

The scope of this issue is to identify all such vulnerabilities and eliminate them by doing the accounting before sending any rewards.

E.g. safe implementation:

function claimTokenRewards() public {
        // our characters go to the tavern
        // and the barkeep pays them for the bounties
        uint256 tokenReward =  tokenRewards[msg.sender];
        tokenRewards[msg.sender] = 0;
        _payPlayerConverted(msg.sender, tokenReward);       
}

Note that we might need to implement handling of failed transfer so in this scenario the amount of unclaimed tokens is reverted to original value.

Market should report active tax percentage

fetchMarketTax function already imported from store into market.vue
it takes the contract address (wep/char) as a parameter and returns a 64x64 fixed point (int128) value
A hint would be well placed next to it that clarifies that it's the buyer who pays the tax and so the seller must keep that in mind while setting their prices

Market shows wrong results when searched for weapons after user lists a weapon

I forged 4 weapons and went to the market.
I listed 2, after which I tried to browse weapons. Of course since i only listed two, before i searched for weapons, there were already the 2 being shown which was left that I forged that I didnt list. When I click browse weapons, my UNlisted weapons didnt disappear and no new weapons appered. I had to go to another page and go back to market and then browse weapons again to the page to show the right weapons

Have wallet switch to correct network

If you switch metamask to eth or some other network, then go to ApeSwap (or refresh), apeswap will ask metamask to switch networks to BSC.

Lots of users tend to forget to check that they are on the right network when switching back and forth. Not sure how it's implemented but I know it's possible.

Error message when faiing to initialize is misleading/confusing

The new page that replaced the "out of gas/ABI error" should probably be replaced with something that says "Can not connect to network. Are you connected to Binance Smart Chain?".

The new info with links to videos and buying skill and amounts needed should take the place of "you dont have any characters, recruit one"

WAX Portal

  • Get WAX wallet signed in to CryptoBlades site
  • Form fill for MEMO {CB WAX address} and {amount}
  • WAX contract call to transfer {amount} with MEMO from user to CB's WAX wallet.
  • On success, call BSC contract to transfer BNB {amount} to logged in MetaMask Wallet

Fight loss improvements

  • Add a 10% chance to roll for a weapon on combat win with a 50% reduction in star-rate
  • Add a 50% XP Gain on fight Loss
  • Add a 33% gain of SKILL on fight loss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.