Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Quentin Vrel
projet-cdaw
Commits
7da2f04f
Commit
7da2f04f
authored
Dec 04, 2020
by
Zohten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
discard
parent
2acedbe3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
23 deletions
+30
-23
Hand.vue
frontend/src/components/Hand.vue
+15
-17
Tile.vue
frontend/src/components/Tile.vue
+8
-3
HandModel.js
frontend/src/model/HandModel.js
+7
-3
No files found.
frontend/src/components/Hand.vue
View file @
7da2f04f
<
template
>
<div
class=
"hand"
v-if=
"this.Hand"
>
<tile
v-for=
"tile of this.Hand.tiles_left"
:key=
"tile.idobject"
:id=
"tile.id_tuile"
/>
<tile
v-for=
"tile of this.Hand.tiles_left"
:key=
"tile.idobject"
:id=
"tile.id_tuile"
@
tileClicked=
"tileClickedListener"
/>
</div>
</
template
>
...
...
@@ -17,28 +17,26 @@ export default {
},
data
(){
return
{
Hand
:
null
Hand
:
null
,
}
},
mounted
(){
let
startingHand
=
[
8
,
11
,
11
,
14
,
16
,
7
,
4
,
5
,
20
,
21
,
22
,
6
,
0
];
this
.
Hand
=
new
Hand
();
this
.
Hand
.
draw
(
new
TileModel
(
8
));
this
.
Hand
.
draw
(
new
TileModel
(
11
));
this
.
Hand
.
draw
(
new
TileModel
(
11
));
this
.
Hand
.
draw
(
new
TileModel
(
14
));
this
.
Hand
.
draw
(
new
TileModel
(
16
));
this
.
Hand
.
draw
(
new
TileModel
(
7
));
this
.
Hand
.
draw
(
new
TileModel
(
4
));
this
.
Hand
.
draw
(
new
TileModel
(
5
));
this
.
Hand
.
draw
(
new
TileModel
(
20
));
this
.
Hand
.
draw
(
new
TileModel
(
21
));
this
.
Hand
.
draw
(
new
TileModel
(
22
));
this
.
Hand
.
draw
(
new
TileModel
(
6
));
this
.
Hand
.
draw
(
new
TileModel
(
0
));
this
.
Hand
.
sort
();
startingHand
.
forEach
(
tile
=>
{
this
.
Hand
.
draw
(
new
TileModel
(
tile
));
});
this
.
Hand
.
sort
();
},
updated
(){
},
methods
:
{
tileClickedListener
:
function
(
tile
){
console
.
log
(
'tile clicked'
);
console
.
log
(
tile
);
let
dicarded
=
this
.
Hand
.
discard
(
tile
);
console
.
log
(
dicarded
);
}
}
}
</
script
>
...
...
frontend/src/components/Tile.vue
View file @
7da2f04f
<
template
>
<div
class=
"tile"
>
<div
class=
"tile-symbol"
:id=
"this.tile.idobject"
>
<div
v-on:click=
"tileClicked(id)"
class=
"tile-symbol"
:id=
"this.tile.idobject"
>
<img
class=
"tile-background"
:src=
"this.background"
:width=
"this.width"
:height=
"this.height"
/>
<!--img class="tile-background" :src="this.background" :width="this.width" :height="this.height"/-->
<svg-button
class=
"tile-front"
:svg=
"this.svg"
:width=
"this.width"
:height=
"this.height"
/>
...
...
@@ -27,11 +27,16 @@ export default {
}
},
mounted
(){
//hook on mounted, we init the object. It could have been done before.
console
.
log
(
typeof
(
this
.
id
));
this
.
tile
=
new
Tile
(
this
.
id
);
this
.
background
=
require
(
"@/assets/img/mahjong-tiles/Black/Front.svg"
);
this
.
svg
=
require
(
"@/assets/img/mahjong-tiles/Black/"
+
this
.
tile
.
getSVG
());
console
.
log
(
this
.
svg
);
},
methods
:
{
tileClicked
:
function
(
id
){
this
.
$emit
(
'tileClicked'
,
{
'id_tuile'
:
id
});
}
}
}
</
script
>
...
...
frontend/src/model/HandModel.js
View file @
7da2f04f
...
...
@@ -12,9 +12,13 @@ export default class Hand{
this
.
claimed
=
[];
}
discard
(
pos
){
var
discarded_tile
=
this
.
tiles_left
.
splice
(
pos
,
1
);
return
discarded_tile
;
discard
(
tile
){
console
.
log
(
'tiles_left'
);
console
.
log
(
this
.
tiles_left
);
const
tile_ids
=
this
.
tiles_left
.
map
(
tile
=>
tile
.
id_tuile
);
console
.
log
(
tile_ids
);
var
index
=
tile_ids
.
indexOf
(
tile
);
return
this
.
tiles_left
.
splice
(
index
,
1
);
}
draw
(
tile
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment