Skip to content
Snippets Groups Projects
Commit f9110d24 authored by Martin Lehoux's avatar Martin Lehoux
Browse files

git

parent f63152cc
No related branches found
No related tags found
No related merge requests found
Showing
with 119 additions and 167 deletions
Mon Feb 18 2019 21:20:58 GMT+0100 (Central European Standard Time)
\ No newline at end of file
Tue Feb 19 2019 18:56:58 GMT+0100 (Central European Standard Time)
\ No newline at end of file
......@@ -30,7 +30,7 @@ app.use(loginChecker);
// Routes
app.use('/users', usersRouter);
// app.use('/characters', charactersRouter);
app.use('/characters', charactersRouter);
mongoose.connect('mongodb://localhost/rolegame', err => {
if (err) {
......
......@@ -8,9 +8,14 @@ const router = express.Router();
const getScore = (data) => Object.keys(data).reduce((total, el) => total + costTable[data[el]], 0);
router.get('/avatars', (req, res) => {
const avatars = fs.readdirSync('../front/public/img/avatars');
res.json({ avatars });
})
router.get('/', async (req, res) => {
// TODO: Login required
const avatars = fs.readdirSync('media/avatars');
Character.find({ user: req.session.user._id }, (err, characters) => {
if (err) return res.status(400).json({ error: err });
return res.json(characters);
......
.ui.card.fluid
.content
img.right.floated.mini.image.ui(src="/media/avatars/"+character.avatar, alt="Avatar")
.header= character.name
.meta
.date Created on #{character.birthDate.toDateString()}
.ui.tiny.progress.yellow.progress(id="action-points-bar-"+character._id)
.bar
.label
span(id="action-points-value-"+character._id)= character.actionPoints
|&nbspaction points
//- .content
//- .ui.label(class=character.attributes.strength<=8 ? "orange" : character.attributes.strength>=12 ? "green" : "" )
//- | Strength
//- .detail= character.attributes.strength
//- .ui.label(class=character.attributes.constitution<=8 ? "orange" : character.attributes.constitution>=12 ? "green" : "" )
//- | Constitution
//- .detail= character.attributes.constitution
//- .ui.label(class=character.attributes.dexterity<=8 ? "orange" : character.attributes.dexterity>=12 ? "green" : "" )
//- | Dexterity
//- .detail= character.attributes.dexterity
//- .ui.label(class=character.attributes.intelligence<=8 ? "orange" : character.attributes.intelligence>=12 ? "green" : "" )
//- | Intelligence
//- .detail= character.attributes.intelligence
//- .ui.label(class=character.attributes.wisdom<=8 ? "orange" : character.attributes.wisdom>=12 ? "green" : "" )
//- | Wisdom
//- .detail= character.attributes.wisdom
//- .ui.label(class=character.attributes.charisma<=8 ? "orange" : character.attributes.charisma>=12 ? "green" : "" )
//- | Charisma
//- .detail= character.attributes.charisma
script $('#action-points-bar-#{character._id}').progress({ total: #{maxActionPoints}, value: #{character.actionPoints}});
script updateActionPoints('#{character._id}', #{character.actionPoints}, #{maxActionPoints});
......@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.0/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.0/semantic.min.css">
<title>front</title>
</head>
<body>
......
<template lang="pug">
sui-card(class="fluid")
sui-card-content
sui-image(floated="right", size="mini", :src="`avatars/${character.avatar}`")
sui-card-header {{ character.name }}
sui-card-meta Created on {{ character.birthDate }}
sui-progress(size="tiny", color="yellow", :label="`${character.actionPoints} action points`", :percent="character.actionPoints/480*100")
</template>
<script>
export default {
name: "CharacterItem",
props: ['character'],
data() {
return {
}
}
// TODO: Update action points
}
</script>
<style scoped>
</style>
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br />
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener"
>vue-cli documentation</a
>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"
>babel</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa"
target="_blank"
rel="noopener"
>pwa</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
target="_blank"
rel="noopener"
>eslint</a
>
</li>
</ul>
<h3>Essential Links</h3>
<ul>
<li>
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
</li>
<li>
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"
>Forum</a
>
</li>
<li>
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"
>Community Chat</a
>
</li>
<li>
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
>Twitter</a
>
</li>
<li>
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
</li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li>
<a href="https://router.vuejs.org" target="_blank" rel="noopener"
>vue-router</a
>
</li>
<li>
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-devtools#vue-devtools"
target="_blank"
rel="noopener"
>vue-devtools</a
>
</li>
<li>
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
>vue-loader</a
>
</li>
<li>
<a
href="https://github.com/vuejs/awesome-vue"
target="_blank"
rel="noopener"
>awesome-vue</a
>
</li>
</ul>
</div>
</template>
<script>
export default {
name: "HelloWorld",
props: {
msg: String
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home.vue";
import Characters from "./views/Characters.vue";
Vue.use(Router);
......@@ -14,13 +15,9 @@ export default new Router({
component: Home
},
{
path: "/about",
name: "about",
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () =>
import(/* webpackChunkName: "about" */ "./views/About.vue")
path: "/characters",
name: "characters",
component: Characters
}
]
});
<template lang="pug">
div
sui-card-group
CharacterItem(v-for="character in characters", :key="character._id", :character="character")
sui-container(text-align="center")
sui-button(color="teal", basic, icon="add", @click="creationModal=true") Create character
sui-modal(v-model="creationModal")
sui-modal-header Create a new character
sui-modal-content(image)
sui-image(size="medium", :src="`avatars/${newCharacter.avatar}`")
sui-modal-description
sui-form(@submit.prevent="")
sui-header Details
sui-form-fields
sui-form-field
sui-input(type="text", v-model="newCharacter.name", placeholder="name")
sui-form-field
sui-dropdown(placeholder="Avatar", selection, :options="avatars", v-model="newCharacter.avatar")
sui-header Attributes: {{ availablePoints }} points remaning
sui-grid
sui-grid-column(:width="8", v-for="attribute in attributes" :key="attribute")
sui-segment
sui-statistic(horizontal)
sui-statistic-value {{ newCharacter.attributes[attribute] }}
sui-statistic-label {{ attribute }}
sui-button(color="orange", circular, floated="left", icon="minus")
sui-button(color="teal", circular, floated="right", icon="add")
sui-progress(attached, bottom, :percent="newCharacter.attributes[attribute]/20*100")
sui-modal-actions
sui-button(color="orange", basic, icon="close", @click="creationModal=false") Cancel
sui-button(color="grey", basic, icon="redo", @click="resetCharacter") Reset
sui-button(color="teal", basic, icon="check") Create
</template>
<script>
import http from "@/http";
import CharacterItem from "@/components/CharacterItem.vue";
export default {
name: "Characters",
components: {
CharacterItem
},
data() {
return {
characters: [{
_id: "13F3V34GBB",
avatar: "boris_by_charro_art_d8eta2f-pre.jpg",
name: "Kagamino",
birthDate: "01-01-1998",
actionPoints: 400
}],
creationModal: false,
newCharacter: { attributes: { } },
avatars: [],
attributes: ['strength', 'constitution', 'dexterity', 'intelligence', 'wisdom', 'charisma'],
availablePoints: 15
}
},
created() {
this.attributes.forEach(attribute => {
this.newCharacter.attributes[attribute] = 10
});
http()
.get('http://localhost:3000/characters/avatars')
.then(res => this.avatars = res.data.avatars.map(avatar => ({ text: avatar, value: avatar })))
},
methods: {
resetCharacter() {
this.characters = { attributes: { } };
this.attributes.forEach(attribute => {
this.newCharacter.attributes[attribute] = 10
});
}
}
}
</script>
<style scoped>
</style>
<template lang="pug">
.home
sui-image(src="img/wallpaper.jpg")
</template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment