Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Mar 5, 2019
0 parents commit e22e95b
Show file tree
Hide file tree
Showing 20 changed files with 16,651 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea/
/node_modules/
16,068 changes: 16,068 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "craeft",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"author": "",
"license": "ISC",
"devDependencies": {
"assert": "^1.4.1",
"create-react-app": "^2.1.5"
},
"dependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-scripts": "2.1.5"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Binary file added public/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
77 changes: 77 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, {Component} from 'react';
import Armor from './engine/items/armor';
import Weapon from './engine/items/weapon';
import Weaoponsmith from './engine/crafter/weaponsmith';
import Armorsmith from './engine/crafter/armorsmith';

class App extends Component {

constructor(props) {
super(props);

this.state = {
crafters: [],
a: 0
};

this.addWS = this.addWS.bind(this);
this.addAS = this.addAS.bind(this);
}

addWS() {
console.log('ws', this.state.crafters);
const crafters = [...this.state.crafters, new Weaoponsmith()];
this.setState({
crafters,
a: crafters.length
});
}

addAS() {
console.log('as', this.state.crafters);
const crafters = [...this.state.crafters, new Armorsmith()];
this.setState({
crafters,
a: crafters.length
});
}

render() {
return (
<div className="App">
<div>
<div>
Crafters:
</div>

<button onClick={this.addWS}>
add weapon smith
</button>

<button onClick={this.addAS}>
add armor smith
</button>

<div>
{
this.state.crafters.map((crafter, index) => {
return (
<div key={index}>
<div>
{crafter.type}: {crafter.name}
</div>
<div>
{crafter.generateDescription()}
</div>
</div>
)
})
}
</div>
</div>
</div>
);
}
}

export default App;
55 changes: 55 additions & 0 deletions src/engine/craeft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const Armor = require('./items/armor');
const Weapon = require('./items/weapon');
const Weaponsmith = require('./crafter/weaponsmith');
const Armorsmith = require('./crafter/armorsmith');

{
const armor = new Armor({def: 10});
armor.print();
}

{
const weapon = new Weapon({atk: 100});
weapon.print();
}

const resources = {
lumber: 100,
iron: 100
};

{
const ws = new Weaponsmith({
luk: 10,
dex: 5,
str: 7
});

ws.print();

const w = ws.craft(
resources
);

w.print();
}

console.log(resources);

{
const as = new Armorsmith({
luk: 10,
dex: 5,
str: 7
});

as.print();

const a = as.craft(
resources
);

a.print();
}

console.log(resources);
27 changes: 27 additions & 0 deletions src/engine/crafter/armorsmith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Armor from '../items/armor';
import Crafter from './crafter';

export default class Armorsmith extends Crafter {
constructor({
name,
luk,
dex,
str
} = {}) {
super({
type: 'Armorsmith',
name,
luk,
dex,
str
});
}

craft(resources) {
return new Armor({
name: 'test',
def: 100,
mdef: 100
});
}
}
45 changes: 45 additions & 0 deletions src/engine/crafter/crafter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { getRandomArrayItem } from '../../tools/rand';

const names = [
'Selar',
'Khemeir',
'Meo',
'Tackath',
'Lirhuk',
'Chioh',
'Umeadrus'
];

export default class Crafter {
constructor({
type = 'unknown',
name = getRandomArrayItem(names),
luk = 0,
dex = 0,
str = 0
} = {}) {
this.type = type;
this.name = name;

this.luk = luk;
this.dex = dex;
this.str = str;
}

craft(
resources
) {
// stub please override
}

generateDescription() {
return `Luk: ${this.luk} Dex: ${this.dex} Str: ${this.str}`
}

print() {
console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
console.log(`Crafter: ${this.name}`);
console.log(this.generateDescription());
console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n');
}
}
27 changes: 27 additions & 0 deletions src/engine/crafter/weaponsmith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Weapon from '../items/weapon';
import Crafter from './crafter';

export default class Weaponsmith extends Crafter {
constructor({
name,
luk,
dex,
str
} = {}) {
super({
type: 'Weaponsmith',
name,
luk,
dex,
str
});
}

craft(resources) {
return new Weapon({
name: 'test',
atk: 100 * this.luk,
matk: 100
});
}
}
26 changes: 26 additions & 0 deletions src/engine/items/armor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Item from './item';
import { getRandomArrayItem } from '../../tools/rand';

const names = [
'Shellmail',
'Platemail'
];

export default class Armor extends Item {

constructor({
def = 0,
mdef = 0
} = {}) {
const name = getRandomArrayItem(names);

super({name});

this.def = def;
this.mdef = mdef;
}

generateDescription() {
return `Def: ${this.def} Mdef: ${this.mdef}`
}
}
18 changes: 18 additions & 0 deletions src/engine/items/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default class Item {
constructor({
name
} = {}) {
this.name = name;
}

generateDescription() {
// stub please override
}

print() {
console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
console.log(`Item: ${this.name}`);
console.log(this.generateDescription());
console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n');
}
}
Loading

0 comments on commit e22e95b

Please sign in to comment.