Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
086c0b0
Select username before first hand
iForgot321 Apr 30, 2022
c6e23aa
Added game summaries on the home page
iForgot321 May 1, 2022
246419d
extend summary
iForgot321 May 3, 2022
551c541
Changed game type to include "complete" and "current round", "current…
Redorangegamez May 3, 2022
ce422eb
Merge remote-tracking branch 'origin/home-page-refactor' into home-pa…
iForgot321 May 5, 2022
df962b9
store game in database everytime a new hand is submitted
iForgot321 May 6, 2022
40cf79f
Updated HK rules for 2022-2023.
Redorangegamez May 7, 2022
23b201c
Add hong kong games to summaries
iForgot321 May 7, 2022
256a7d4
widen username css for summaries
iForgot321 May 7, 2022
55de71b
Update HKG Mistake points to 600
Redorangegamez May 7, 2022
ea1dec0
added riichi stick storage
iForgot321 May 7, 2022
5a371ed
Merge remote-tracking branch 'origin/home-page-refactor' into home-pa…
iForgot321 May 7, 2022
fd879ac
moved session set stuff
iForgot321 May 7, 2022
00ed965
Changed constant name for HKG_PAO
Redorangegamez May 8, 2022
33f6fa9
database saves session stuff
Redorangegamez May 8, 2022
9934408
Merge branch 'master' into home-page-refactor
Redorangegamez May 8, 2022
11fb5ad
Hong Kong live games and cookies done.
Redorangegamez May 12, 2022
d2018eb
record game ui bug fix
Redorangegamez May 15, 2022
9a0da3d
Live Game Modal Added
Redorangegamez May 16, 2022
883c36d
live game modal css fixes
iForgot321 May 16, 2022
228e68d
HK Pao Hotfix
Redorangegamez May 17, 2022
27c7d5c
Changed database calls
Redorangegamez Aug 8, 2022
5da5a1f
Added TTL for in-progress Japanese and Hong Kong hands
iForgot321 Aug 8, 2022
7a7a4d7
Added Hong Kong calls
Redorangegamez Aug 8, 2022
34c2145
Merge remote-tracking branch 'origin/home-page-refactor' into home-pa…
iForgot321 Aug 8, 2022
559b2c4
various bug fixes
iForgot321 Aug 8, 2022
81be061
changed time for game deletion from 6 to 24 hours.
Redorangegamez Sep 1, 2022
a30b8b4
Merge remote-tracking branch 'origin/home-page-refactor' into home-pa…
Redorangegamez Sep 1, 2022
b403a78
added favicon
iForgot321 Sep 30, 2022
73dbc0f
added optional chaining to fix console output
iForgot321 Sep 30, 2022
c6c0a42
Merge branch 'master' into home-page-refactor
iForgot321 Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/Main.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<head>
<title>MJCApp</title>
<link rel="shortcut icon" href="../client/images/favicon.ico" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
</head>
Binary file added client/images/favicon.ico
Binary file not shown.
50 changes: 50 additions & 0 deletions client/stylesheets/Home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.game-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}

.summary-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 8px;
margin: 8px;
border: 3px solid black;
border-radius: 8px;
font-family: "Helvetica Neue";
font-size: 20px;
cursor: pointer;
}

.summary-container:hover {
background-color: #eee;
}

.summary-column-container {
display: flex;
margin: 12px 0;
}

.summary-column-container > div {
margin: 0 8px;
}

.winds {
text-align: left;
}

.points {
text-align: right;
}

.username {
width: 180px;
}

.username > div {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
4 changes: 4 additions & 0 deletions client/Main.css → client/stylesheets/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ tr:nth-of-type(even){
.names th, td {
text-align: center;
}

table th {
text-align: center;
}
2 changes: 1 addition & 1 deletion imports/api/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ const Constants = {
DEAL_IN: "dealin",
SELF_DRAW: "selfdraw",
NO_WIN: "nowin",
RESTART: "restart",
PAO: "pao",
RESTART: "restart",
MISTAKE: "mistake",

// Direction Constants
Expand Down
273 changes: 272 additions & 1 deletion imports/api/GameDatabases.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions imports/ui/Index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template name="Index">
<u1 class="nav nav-tabs nav-justified">
<!--comment-->
<li data-template="Home" role="presentation" class="active">
<li id="Home" data-template="Home" role="presentation">
<a data-toggle="tab" href="#">Home</a>
</li>

Expand Down Expand Up @@ -30,7 +30,7 @@
</u1>
</li>

<li data-template="About" role="presentation">
<li id="About" data-template="About" role="presentation">
<a data-toggle="tab" href="#">About</a>
</li>
</u1>
Expand Down
16 changes: 14 additions & 2 deletions imports/ui/Index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import './static/About.html';
import './static/Home.html';
import './Index.html';

import './home/Home';
import './record-game/RecordHongKongGame';
import './record-game/RecordJapaneseGame';
import './ranking/Ranking';

Template.Index.onCreated( function() {
this.currentTab = new ReactiveVar( "Home" );
if (localStorage.getItem("game_id") !== null) {
if (localStorage.getItem("game_type") === "jp") {
this.currentTab = new ReactiveVar( "RecordJapaneseGame" );
} else if (localStorage.getItem("game_type") === "hk") {
this.currentTab = new ReactiveVar( "RecordHongKongGame" );
}
} else {
this.currentTab = new ReactiveVar( "Home" );
}
});

Template.Index.onRendered( function() {
$("#" + this.currentTab.curValue).addClass( "active" );
});

Template.Index.helpers({
Expand Down
44 changes: 44 additions & 0 deletions imports/ui/home/Home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template name="Home">
<h2>Home</h2>
{{ > LiveJapaneseGameModal }}
{{ > LiveHongKongGameModal }}
<div class="game-list">
{{#each jpn_game in jpn_games}}
{{> game_summary game=jpn_game name="Riichi" type="japanese"}}
{{/each}}
{{#each hk_game in hk_games}}
{{> game_summary game=hk_game name="Hong Kong" type="hongKong"}}
{{/each}}
</div>
</template>

<template name="game_summary">
<div class="summary-container"
data-game="{{ game._id }}"
data-type="{{ type }}" >
<div>{{name}}</div>
<div class="summary-column-container">
<div class="winds">
<div>East</div>
<div>South</div>
<div>West</div>
<div>North</div>
</div>
<div class="username">
<div>{{game.east_player}}</div>
<div>{{game.south_player}}</div>
<div>{{game.west_player}}</div>
<div>{{game.north_player}}</div>
</div>
<div class="points">
<div>{{displayScore game.east_score type}}</div>
<div>{{displayScore game.south_score type}}</div>
<div>{{displayScore game.west_score type}}</div>
<div>{{displayScore game.north_score type}}</div>
</div>
</div>
<div>
{{displayRoundWind game.current_round type}} {{displayRoundNumber game.current_round type}} Bonus {{game.current_bonus}}
</div>
</div>
</template>
66 changes: 66 additions & 0 deletions imports/ui/home/Home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Template } from 'meteor/templating';
import Constants from '../../api/Constants';
import GameRecordUtils from '../../api/utils/GameRecordUtils';

import { InProgressJapaneseHands, InProgressHongKongHands, Players } from '../../api/GameDatabases';

import './LiveJapaneseGameModal';
import './LiveHongKongGameModal';
import './Home.html';

Template.Home.onCreated( function() {
Meteor.call('canRetrievePlayer', function (error, game) {
return;
});
});

Template.Home.helpers({
jpn_games() {
return InProgressJapaneseHands.find().fetch();
},
hk_games() {
return InProgressHongKongHands.find().fetch();
}
});

Template.game_summary.helpers({
displayScore(score, game_type) {
if (game_type == Constants.GAME_TYPE.JAPANESE) {
return (score / 1000).toFixed(1);
} else {
return score;
}
},
displayRoundWind(round, game_type) {
if (game_type == Constants.GAME_TYPE.JAPANESE) {
return GameRecordUtils.displayRoundWind(round, Constants.GAME_TYPE.JAPANESE);
} else {
return GameRecordUtils.displayRoundWind(round, Constants.GAME_TYPE.HONG_KONG);
}
},
displayRoundNumber(round, game_type) {
if (game_type == Constants.GAME_TYPE.JAPANESE) {
return GameRecordUtils.handNumberToRoundNumber(round, Constants.GAME_TYPE.JAPANESE);
} else {
return GameRecordUtils.handNumberToRoundNumber(round, Constants.GAME_TYPE.HONG_KONG);
}
},

});

Template.Home.events({
'click .summary-container': (event) => {
event.preventDefault();
let game_type = event.currentTarget.dataset["type"];
if (game_type == Constants.GAME_TYPE.JAPANESE) {
let game = InProgressJapaneseHands.findOne(event.currentTarget.dataset["game"]);
Session.set("game_summary", game);
console.log(game);
$("#jpn-game-modal").modal('show');
} else {
let game = InProgressHongKongHands.findOne(event.currentTarget.dataset["game"]);
Session.set("game_summary", game);
$("#hk-game-modal").modal('show');
}
},
})
104 changes: 104 additions & 0 deletions imports/ui/home/LiveHongKongGameModal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<template name="LiveHongKongGameModal">
<div class="modal fade" id="hk-game-modal" tabindex="-1" role="dialog">
<div class="modal-dialog" style="width:90%" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h2 class="modal-title">Live Game</h2>
</div>
<div class="modal-body" style="overflow: scroll">
<table style="width:100%">
<tr>
<th colspan="3"></th>
<th>{{get_east_player}}</th>
<th>{{get_south_player}}</th>
<th>{{get_west_player}}</th>
<th>{{get_north_player}}</th>
</tr>
<tr>
<th>Round</th>
<th>Bonus</th>
<th>Points</th>
<th>{{HKG_START_POINTS}}</th>
<th>{{HKG_START_POINTS}}</th>
<th>{{HKG_START_POINTS}}</th>
<th>{{HKG_START_POINTS}}</th>
</tr>
{{#each hands}}
{{> hk_render_hand}}
{{/each}}
<tr>
<td>
{{displayRoundWind get_round}} {{displayRoundNumber get_round}}
</td>
<td>B {{get_bonus}}</td>
</tr>
<tr>
<th colspan="3">Transaction total:</th>
<td>{{get_player_delta EAST}}</td>
<td>{{get_player_delta SOUTH}}</td>
<td>{{get_player_delta WEST}}</td>
<td>{{get_player_delta NORTH}}</td>
</tr>
<tr>
<th colspan="3">Current score:</th>
<td>{{get_player_score EAST}}</td>
<td>{{get_player_score SOUTH}}</td>
<td>{{get_player_score WEST}}</td>
<td>{{get_player_score NORTH}}</td>
</tr>
<tr>
<th colspan="3">End score:</th>
<td>{{get_player_score_final EAST}}</td>
<td>{{get_player_score_final SOUTH}}</td>
<td>{{get_player_score_final WEST}}</td>
<td>{{get_player_score_final NORTH}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</template>


<template name="hk_render_hand">
<tr>
<td>
{{displayRoundWind round}} {{displayRoundNumber round}}
</td>
<td>B {{bonus}}</td>

{{#if is_dealin handType}}
<td>{{points}}</td>
<td>{{eastDelta}}</td>
<td>{{southDelta}}</td>
<td>{{westDelta}}</td>
<td>{{northDelta}}</td>
{{/if}}

{{#if is_selfdraw handType}}
<td>{{points}}</td>
<td>{{eastDelta}}</td>
<td>{{southDelta}}</td>
<td>{{westDelta}}</td>
<td>{{northDelta}}</td>
{{/if}}

{{#if is_nowin handType}}
<td>No win!</td>
{{/if}}

{{#if is_restart handType}}
<td>Reshuffle!</td>
{{/if}}

{{#if is_mistake handType}}
<td>Mistake!</td>
<td>{{eastDelta}}</td>
<td>{{southDelta}}</td>
<td>{{westDelta}}</td>
<td>{{northDelta}}</td>
{{/if}}
</tr>
</template>
Loading