Compare commits

..
Author SHA1 Message Date
FernandoJVideira 3a7b1b9794 fix:websocket errors & polict change 2026-01-02 14:26:54 +00:00
AfonsoCMSousa ef277a3cfd Merge pull request 'Issues Websockets #48 #49 #51 e #54' (#91) from feature/websockets-game-continue into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/91
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
2026-01-02 13:33:21 +00:00
KZix e23ca3d1ff Issues Websockets #48 #49 #51 e #54 2026-01-02 13:24:20 +00:00
FernandoJVideira bcdf542606 Merge pull request 'Created statistics personal and general' (#90) from feature/statistics into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/90
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2026-01-01 12:34:40 +00:00
Edd 16f8d3bdfc Created statistics personal and general 2025-12-31 23:57:54 +00:00
AfonsoCMSousa 45d8aa0035 Merge pull request 'Implemented coin purchase-flow' (#89) from feature/coin-purchase into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/89
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
2025-12-31 22:41:09 +00:00
Edd c0af76abd3 Implemented coin purchase-flow 2025-12-31 18:28:29 +00:00
FernandoJVideira ff16a57a97 Merge pull request 'Bugfix: Added api logic with transactions when match is finished, started and joined' (#88) from bugfix/matches-transactions into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/88
Reviewed-by: Edd <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-31 15:54:20 +00:00
KZix cf238d5451 Added api logic with transactions when match is finished, started and joined 2025-12-31 15:48:24 +00:00
Edd 50ae1b7f1f Merge pull request 'Added endpoint to create tranasactions' (#87) from feature/api-coinpurchase into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/87
Reviewed-by: Edd <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-31 11:07:11 +00:00
KZix 5975208877 Added endpoint to create tranasactions 2025-12-31 01:13:27 +00:00
KZix f3e8ffc400 Merge pull request 'matches and transactions history fully operational' (#86) from na/fix-histories into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/86
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-31 00:31:59 +00:00
Edd 1b03558f93 matches and transactions history fully operational 2025-12-31 00:16:14 +00:00
AfonsoCMSousa 881a60a388 Merge pull request 'feature/api-adminstats-transactions' (#85) from feature/api-adminstats-transactions into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/85
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
2025-12-30 19:24:49 +00:00
KZix cf3ca26382 removed comments on code 2025-12-30 19:17:49 +00:00
KZix 58e6615876 Merge branch 'develop' into feature/api-adminstats-transactions 2025-12-30 19:02:09 +00:00
KZix 9bfa06b1ce Added endpoint to get authenticated user's transactions 2025-12-30 19:01:02 +00:00
Edd 2a438dce26 Merge pull request 'feat: api users change password endpoint' (#84) from feature/api-update-password into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/84
Reviewed-by: KZix <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-30 17:17:06 +00:00
KZix f38f08923f Added transaction details for the logged user 2025-12-30 16:13:46 +00:00
KZix 5f845b2ba7 Added routes, admin statistics to the controller and added models for coin transaction and coin transaction type 2025-12-30 16:08:53 +00:00
FernandoJVideira 54b4fc7cb1 feat: api users change password endpoint 2025-12-30 10:55:46 +00:00
KZix 3d23627433 Merge pull request 'register, coin balance, game history and transactions mockup' (#83) from na/history-and-register into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/83
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-30 10:24:15 +00:00
Edd 4f391e3638 histories are a little messed, will change the logic in the future (techdebt) 2025-12-30 01:49:39 +00:00
FernandoJVideira c456c9482f Merge pull request 'feature/api-stats' (#82) from feature/api-stats into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/82
Reviewed-by: Edd <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-29 19:08:47 +00:00
KZix 754a227608 Merge branch 'develop' into feature/api-stats 2025-12-29 19:07:38 +00:00
KZix 83f92e670d Merge pull request 'feature/api-admin-policies' (#78) from feature/api-admin-policies into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/78
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: Edd <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-29 17:11:15 +00:00
KZix 59df3e2d37 Added protection to Nickname and added user get coins endpoint 2025-12-29 15:59:25 +00:00
KZix 39f55a12c0 Adde routes for statistics 2025-12-29 15:40:23 +00:00
KZix edecef3af8 added StatisticsController.php and changed the User.php model and ProfileController.php that were missing some imports 2025-12-29 15:34:56 +00:00
FernandoJVideira 51f745a3dd Merge branch 'develop' into feature/api-admin-policies 2025-12-29 14:53:44 +00:00
FernandoJVideira 4b311c74eb fix: added missing route 2025-12-29 14:47:32 +00:00
FernandoJVideira 0ecdc30bd4 fix: removed .env 2025-12-29 11:15:50 +00:00
FernandoJVideira 25c819c6e4 feat: api admin user and game policies 2025-12-29 11:15:50 +00:00
KZixandFernandoJVideira f60b25f29b chore: stop tracking package-lock.json 2025-12-29 11:15:50 +00:00
KZixandFernandoJVideira 52887fc2eb SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 added packagelock.json to gitignore 2025-12-29 11:15:50 +00:00
KZixandFernandoJVideira c4078d9b82 SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 added sockets for game joining and card play 2025-12-29 11:15:50 +00:00
KZixandFernandoJVideira d29e44c61c Added dummy user to create a game 2025-12-29 11:15:49 +00:00
KZixandFernandoJVideira 8f7102b335 SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 Added initial setup for websockets 2025-12-29 11:15:49 +00:00
EddandFernandoJVideira a34027889f remove package-lock 2025-12-29 11:15:49 +00:00
EddandFernandoJVideira 87e0dc2518 home page feature final 2025-12-29 11:15:49 +00:00
KZixandFernandoJVideira 79be3544cb SyntaxSquad/DADProject#14 missed one file 2025-12-29 11:15:35 +00:00
KZixandFernandoJVideira eafb4a4d1c SyntaxSquad/DADProject#14 added surrender button 2025-12-29 11:15:34 +00:00
KZixandFernandoJVideira 08c20acdf4 SyntaxSquad/DADProject#14 Added final touches to the gameplay 2025-12-29 11:15:34 +00:00
KZixandFernandoJVideira ab231ee94f SyntaxSquad/DADProject#14 fixed routes 2025-12-29 11:15:34 +00:00
KZixandFernandoJVideira ceb3d735ad SyntaxSquad/DADProject#14 Bot works and play works, still has some bugs 2025-12-29 11:15:34 +00:00
KZixandFernandoJVideira 5924d08f73 SyntaxSquad/DADProject#14 added start logic for bot 2025-12-29 11:15:33 +00:00
KZixandFernandoJVideira 3ec6f8971c SyntaxSquad/DADProject#14 added protection to logout inside a game and going to another page 2025-12-29 11:15:33 +00:00
KZixandFernandoJVideira e68f1357cc Added game start for single player, 3 and 9 card game types and protected the pages for only logged in players 2025-12-29 11:15:20 +00:00
FernandoJVideira cfda949ea6 feat: gameboard ui 2025-12-29 11:15:02 +00:00
EddandFernandoJVideira c68cda350e home page feature part 1 2025-12-29 11:13:22 +00:00
FernandoJVideira b7daa4610b tmp: pc change 2025-12-29 09:43:25 +00:00
FernandoJVideira 329bbcc1d3 Merge pull request 'feature/initial_gameplay_websockets' (#77) from feature/initial_gameplay_websockets into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/77
Reviewed-by: Edd <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-28 18:05:52 +00:00
KZix b35cac3b2c chore: stop tracking package-lock.json 2025-12-28 16:54:01 +00:00
KZix b5c3c552da SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 added packagelock.json to gitignore 2025-12-28 16:45:23 +00:00
KZix 14dd4b3a4e SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 added sockets for game joining and card play 2025-12-28 16:34:51 +00:00
KZix 0d0f7569a6 Added dummy user to create a game 2025-12-28 16:30:18 +00:00
KZix 09c4732e19 SyntaxSquad/DADProject#46 SyntaxSquad/DADProject#47 Added initial setup for websockets 2025-12-27 19:52:46 +00:00
FernandoJVideira d4361121d8 feat: api admin policies 2025-12-27 15:07:48 +00:00
KZix ef0bdab0d3 Merge pull request 'Build game lobby for single-player and multiplayer modes' (#76) from feature/home-page into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/76
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-25 11:42:00 +00:00
Edd 5295d0620f remove package-lock 2025-12-25 01:51:47 +00:00
Edd d8cdbbf2ad home page feature final 2025-12-25 01:49:02 +00:00
Edd 160489b080 Merge branch 'develop' into feature/home-page 2025-12-24 23:42:00 +00:00
Edd a0bbd8a69d Merge pull request 'SyntaxSquad/DADProject#14 feature/frontend-gameboard-singleplayer' (#75) from feature/frontend-gameboard-singleplayer into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/75
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-24 23:35:40 +00:00
Edd 943a5dd898 Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-24 23:35:33 +00:00
KZix 8912029686 SyntaxSquad/DADProject#14 missed one file 2025-12-24 16:02:03 +00:00
KZix 0bf96fc948 SyntaxSquad/DADProject#14 added surrender button 2025-12-24 16:00:53 +00:00
FernandoJVideira 79310fa63e Merge pull request 'feat: api admin users endpoints' (#74) from feature/api-admin-user-endpoint into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/74
Reviewed-by: KZix <[email protected]>
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
2025-12-24 15:54:11 +00:00
KZix 83adbcf2f1 Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-24 15:48:49 +00:00
KZix 00666a16b2 SyntaxSquad/DADProject#14 Added final touches to the gameplay 2025-12-24 15:48:16 +00:00
FernandoJVideira 026e7af6a5 feat: api admin users endpoints 2025-12-24 15:03:37 +00:00
FernandoJVideira 7cfe9d2746 Merge pull request 'feature/account-deletion' (#73) from feature/account-deletion into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/73
Reviewed-by: KZix <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-24 10:52:01 +00:00
KZix 7a6fbb4ba3 SyntaxSquad/DADProject#14 fixed routes 2025-12-23 22:02:40 +00:00
KZix f3f6c6e564 Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-23 21:55:23 +00:00
KZix d8e20dfc67 SyntaxSquad/DADProject#14 Bot works and play works, still has some bugs 2025-12-23 21:52:09 +00:00
AfonsoCMSousa 381f30a0f5 Merge branch 'develop' into feature/account-deletion 2025-12-23 21:52:05 +00:00
AfonsoCMSousa 723d5270e4 Merge pull request 'feature/profile-page' (#71) from feature/profile-page into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/71
Reviewed-by: KZix <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-23 21:49:20 +00:00
AfonsoCMSousa f4aaf9a787 Merge branch 'develop' into feature/profile-page 2025-12-23 21:45:33 +00:00
AfonsoCMSousa 30705fd194 SyntaxSquad/DADProject#10 feat: Account deletion (soft delete) 2025-12-23 21:39:38 +00:00
KZix 1939822e9b Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-23 20:12:01 +00:00
KZix c0b77aebb1 SyntaxSquad/DADProject#14 added start logic for bot 2025-12-23 20:08:19 +00:00
Edd ea15f5e28a Merge remote-tracking branch 'origin/develop' into feature/home-page 2025-12-23 20:07:35 +00:00
KZix 44c0ac599e Merge pull request 'Fix auth' (#72) from na/fix-auth into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/72
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-23 20:06:43 +00:00
Edd 28466ecbbd Merge branch 'develop' into na/fix-auth 2025-12-23 20:05:44 +00:00
Edd e47a453588 remove comment 2025-12-23 20:05:17 +00:00
Edd 0320230279 fix auth 2025-12-23 20:03:59 +00:00
KZix 8505d207e6 SyntaxSquad/DADProject#14 added protection to logout inside a game and going to another page 2025-12-23 19:43:57 +00:00
AfonsoCMSousa c34d74db46 SyntaxSquad/DADProject#9 fixforthefix: Remove anoying gray bg 2025-12-23 18:53:11 +00:00
AfonsoCMSousa 18cef8da4b SyntaxSquad/DADProject#9 fix: Used Tailwind Classes and Exported inline CSS into "UserPage.css" 2025-12-23 18:42:09 +00:00
AfonsoCMSousa b82b4d5b59 SyntaxSquad/DADProject#9 feat: Added profile change and name/password changes. 2025-12-23 18:21:04 +00:00
AfonsoCMSousa 29fc78c9f5 Merge remote-tracking branch 'origin/develop' into feature/profile-page 2025-12-23 17:35:49 +00:00
AfonsoCMSousa d903f96d57 SyntaxSquad/DADProject#9 Actuall User View 2025-12-23 17:24:25 +00:00
KZix e54ec58f0c Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-23 15:25:45 +00:00
Edd 7d1b769bdb Merge pull request 'Fixed Endpoint file and GameController' (#70) from fix/api-endpoints into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/70
Reviewed-by: KZix <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-23 14:58:27 +00:00
Edd d0f9a03b93 Merge branch 'develop' into fix/api-endpoints 2025-12-23 12:38:51 +00:00
FernandoJVideira 10508cc0b1 fix: GameControler create game fixed 2025-12-23 12:36:56 +00:00
FernandoJVideira c78c5d2784 fix: api.php cleanup 2025-12-23 12:34:19 +00:00
KZix e833e403f7 Added game start for single player, 3 and 9 card game types and protected the pages for only logged in players 2025-12-23 00:18:34 +00:00
KZix 5c1fc11975 Merge branch 'develop' into feature/frontend-gameboard-singleplayer 2025-12-22 19:41:26 +00:00
Edd b59640c858 Merge branch 'develop' into feature/home-page 2025-12-22 17:14:56 +00:00
FernandoJVideira 289e8df604 Merge pull request 'Implement login page with email/password authentication' (#69) from feature/login-page into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/69
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-22 17:08:37 +00:00
Edd e8ccea4e42 home page feature part 1 2025-12-21 23:12:13 +00:00
Edd 8e179200a5 Merge branch 'develop' into feature/login-page 2025-12-21 14:52:32 +00:00
Edd c03d49e7e4 removed vscode preferences 2025-12-21 02:37:46 +00:00
Edd 2734e25cce feature implement login final changes 2025-12-20 22:26:22 +00:00
Edd a566387998 feature implement login part2 2025-12-20 21:59:33 +00:00
FernandoJVideira 2b161e2099 feat: gameboard ui 2025-12-20 17:03:18 +00:00
AfonsoCMSousa d1dd2c00f6 SyntaxSquad/DADProject#9 feat: User info dysplayed in /users/ 2025-12-18 21:04:49 +00:00
FernandoJVideira 8a6e0d0255 Merge pull request 'Added routes, endpoints to get all matches, get a specific match, create a match, join a match, and update the match' (#68) from feature/matches-api-endpoints into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/68
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-18 20:36:49 +00:00
KZix b485e19c9d Added routes, endpoints to get all matches, get a specific match, create a match, join a match, and update the match 2025-12-18 20:29:10 +00:00
AfonsoCMSousa 94fdbd568c Merge branch 'develop' into feature/profile-page 2025-12-18 19:15:49 +00:00
Edd ae6a0b4706 Merge branch 'develop' into feature/login-page 2025-12-18 19:11:47 +00:00
Edd 5270e3c093 Merge pull request 'feature/game-endpoints' (#62) from feature/game-endpoints into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/62
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-14 00:56:05 +00:00
KZix 5473a4cc69 removed crap i did, sorry frontends 2025-12-14 00:28:58 +00:00
KZix cf8f93d984 Added endpoits to create, join and update the game state, playability should work now 2025-12-14 00:26:41 +00:00
KZix 7686aff546 Added initial game logic 2025-12-12 00:05:37 +00:00
AfonsoCMSousa a0ad35bb08 Merge branch 'feature/login-page' into feature/profile-page 2025-12-11 21:18:31 +00:00
KZix af41990807 Merge pull request 'Added the register endpoint' (#61) from feature/register-api-endpoint into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/61
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-11 21:18:05 +00:00
KZix 20f53197ec Merge branch 'develop' into feature/register-api-endpoint 2025-12-11 21:17:58 +00:00
KZix 7c6d8ed446 Merge pull request 'feat: websocket init' (#60) from feature/websocket-init into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/60
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: KZix <[email protected]>
2025-12-11 21:17:23 +00:00
AfonsoCMSousa 1d5100fbdf feat:initial commit 2025-12-11 21:14:54 +00:00
Edd 511e645d7e feature implement login part 1 2025-12-11 21:14:25 +00:00
KZix daa72ce4c6 Added the register endpoint 2025-12-11 21:13:56 +00:00
AfonsoCMSousa 117f007b83 Merge branch 'develop' into feature/websocket-init 2025-12-11 21:05:10 +00:00
FernandoJVideira 69705ce61c feat: websocket init 2025-12-11 21:02:02 +00:00
FernandoJVideira 8472263f91 Merge pull request 'feature/database-and-auth-api' (#59) from feature/database-and-auth-api into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/59
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: FernandoJVideira <[email protected]>
2025-12-11 20:47:09 +00:00
KZix d7a6862dcb Added necessary stuff for authentication 2025-12-11 20:42:30 +00:00
FernandoJVideira a335e713ee Merge pull request 'Rebase Develop' (#58) from master into develop
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/58
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
Reviewed-by: KZix <[email protected]>
Reviewed-by: Edd <[email protected]>
2025-12-04 21:01:39 +00:00
FernandoJVideira 1e5792567f Merge pull request 'Added base project' (#57) from na/change-project-base into master
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/57
Reviewed-by: FernandoJVideira <[email protected]>
Reviewed-by: Edd <[email protected]>
Reviewed-by: Afonso Clerigo Mendes de Sousa <[email protected]>
2025-12-04 20:56:11 +00:00
KZix 2f47f69adb Added base project 2025-12-04 20:45:22 +00:00
KZix dc16a150e1 Merge pull request 'feature/database-and-start' (#3) from feature/database-and-start into master
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/3
Reviewed-by: Edd <[email protected]>
2025-11-20 20:38:44 +00:00
KZix 4ac9487605 Added tailwindcss, the main pages to create the Website and routes 2025-11-13 22:31:20 +00:00
KZix 98a2ca4611 Added database structure and components 2025-11-13 21:27:45 +00:00
Edd 3f1c69c15b Merge pull request 'Project Structure Fixed And Code Cleanup' (#2) from cleanup into master
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/2
2025-11-08 20:27:52 +00:00
FernandoJVideira 7d91521d64 fix:remove vendor 2025-11-08 20:17:56 +00:00
FernandoJVideira eb056ee995 fix:code cleanup 2025-11-08 20:12:34 +00:00
FernandoJVideira d2e7a50ce5 fix:repo cleanup 2025-11-08 20:09:52 +00:00
FernandoJVideira dedcc73567 fix:repo cleanup 2025-11-08 20:09:07 +00:00
FernandoJVideira f1da93791d Merge pull request 'Added Project structure, API, Frontend and Websockets' (#1) from init into master
Reviewed-on: https://gitea.fernandovideira.com/SyntaxSquad/DADProject/pulls/1
Reviewed-by: FernandoJVideira <[email protected]>
2025-11-08 19:42:27 +00:00
8675 changed files with 15245 additions and 999930 deletions
+85 -115
View File
@@ -1,138 +1,108 @@
# ---> Node
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# -------------------------
# Project-level .gitignore
# Root: DADProject
# -------------------------
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# macOS
.DS_Store
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
# parcel / next / nuxt / vite / etc caches
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# vitepress build output
**/.vitepress/dist
# vitepress cache directory
**/.vitepress/cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# -------------------------
# Frontend: Vue (in frontend/)
# -------------------------
# Node deps and build output for the Vue app
/frontend/node_modules/
/frontend/dist/
/frontend/build/
/frontend/.cache/
/frontend/.vite/
/frontend/.serverless/
/frontend/.vscode/
# Vue / Vite / Vue CLI env files (local)
frontend/.env
frontend/.env.local
frontend/.env.*.local
# Misc frontend files that should be ignored
/frontend/public/hot
/frontend/public/storage
# -------------------------
# Backend: PHP / Laravel (in api/)
# -------------------------
/api/vendor/
/api/node_modules/
/api/vscode/
/api/.env
/api/.env.*.local
# Laravel storage and compiled files
/api/storage/
/api/storage/*.key
/api/public/storage
/api/bootstrap/cache/*.php
# Homestead / vagrant
/api/.vagrant
/api/Homestead.yaml
/api/Homestead.json
# composer
/api/.composer/
/api/.composer-cache
# Laravel specific tooling
/api/.phpunit.result.cache
# -------------------------
# Websockets: NodeJs (in websockets)
# -------------------------
/websockets/node_modules/
/websockets/.env
# -------------------------
# Other useful ignores
# -------------------------
# Generated environment files used by editors/OS
Thumbs.db
ehthumbs.db
Desktop.ini
# Logs and runtime files
*.log
*.tmp
*.temp
# Certificate/key files
*.pem
*.key
# If you have any local secrets or files not to track, add them here:
# /path/to/some/file
/frontend/package-lock.json
/websockets/package-lock.json
/api/package-lock.json
.vscode
+253 -1
View File
@@ -1,2 +1,254 @@
# DADProject
# DAD Project - Bisca Game Platform
## Overview
The DAD project aims to develop and deploy the **Bisca Game Platform** as a web application. The platform is a distributed system that provides users with the ability to play the traditional Portuguese card game Bisca in single-player and multiplayer modes, manage their coins, and track their gaming statistics.
The web client is implemented as a **Single-Page Application (SPA)** built with **Vue.js** and hosted on the designated internal school server. The backend system includes a database, a RESTful API server, and a WebSocket server for real-time multiplayer gameplay.
## Project Architecture
### Frontend
- **Technology**: Vue.js SPA
- **Purpose**: User interface for game play, user management, coin transactions, and statistics visualization
- **Features**: Real-time game updates via WebSockets, responsive design, player profiles, leaderboards
### Backend
- **RESTful API Server**: Handles user authentication, coin transactions, game history, leaderboards, and administrative operations
- **WebSocket Server**: Manages real-time multiplayer game communication, ensuring the server acts as the authoritative source for game state
- **Database**: Persists user data, game results, transactions, and platform statistics
## Constraints
The project must adhere to the following mandatory constraints:
1. **Single-Page Application (SPA)** - The application must be implemented exclusively as an SPA
2. **Vue.js Requirement** - The client application must be built with Vue.js
3. **Payment Gateway Integration** - All external coin purchases must be processed via the provided RESTful API (Payment Gateway Service)
4. **Deployment** - The application must be deployed on the designated internal school server and be accessible via a desktop web browser
5. **Backend Technologies** - Must be open-source or available as free external services
6. **Server Compatibility** - Backend technologies must be installable on or accessible from the designated server; if not supported, compliant alternatives must be selected
7. **Database Seeding** - The deployed application's database must be seeded with realistic data in both scale and content to simulate typical usage patterns
## Core Features
### 1. User Management
- **Registration**: Users register with email, nickname, name, password (minimum 3 characters), and optional photo/avatar
- **Authentication**: Email and password-based login
- **Profile Management**: View and update profile information, change password
- **Sign Out**: Users can end their session
- **Account Deletion**: Requires explicit confirmation; permanently forfeits all coins
- **Welcome Bonus**: New users receive 10 coins upon registration
- **Admin Accounts**: Created only by existing administrators; same profile capabilities as users but cannot delete their own accounts
### 2. Coins and Transactions
- **Coin Balance**: Users can view their current coin balance
- **Coin Purchases**: External purchases via Payment Gateway Service
- **Conversion Rate**: €1 = 10 coins (purchases in €1 increments)
- **Coin Earning**: Players earn coins through gameplay and bonuses
- **Transaction History**: All coin-related transactions (bonuses, purchases, spending, earnings) are logged
- **History Access**:
- Players view only their own transaction history
- Administrators have read-only access to all players' histories
- Administrators cannot create, modify, or delete transactions
### 3. Games and Matches
#### Game Variants
- **Bisca de 3**: Three-card hands
- **Bisca de 9**: Nine-card hands
#### Game Modes
- **Single-Player**: Against a bot (available to anonymous and registered users)
- **Multiplayer**: Against human opponents (available only to registered users)
- **Match**: Best-of series (up to 4 marks/wins) with two players
#### Game Rules
- Games and matches are limited to two players
- The bot follows game rules and attempts to win when playing second; otherwise plays its lowest-value card
- Official Bisca rules apply (as defined in the "Bisca Game" documentation)
#### Multiplayer Gameplay
- **Real-Time Communication**: WebSockets for live game updates
- **Server Authority**: The server is the source of truth for:
- Card dealing
- Turn order
- Valid moves
- Trick resolution
- Drawing from stock
- Scoring
- End-of-game/match conditions
- **Move Timer**: 20-second limit per move
- **Resignation**:
- Opponent awarded all remaining cards
- Game ends immediately
- If in a match, player forfeits all remaining games
- Scores computed accordingly
- **Persistent Results**: Game and match results with metadata are persisted for user history and administrative access
### 4. Game History and Leaderboards
#### Tracking
- **Scope**: Only multiplayer games and matches are tracked
- **Metadata**: Start/end timestamps, variant, outcome (win/loss/draw/forfeit), final points, marks (capote, bandeira), duration
#### History Access
- **Players**: View only their own multiplayer history
- **Administrators**: Read-only access to all players' histories and detailed records
- **Detailed Records**: Visible only to administrators and participating players
#### Leaderboards
- **Personal Leaderboards**: Visible only to the owner; summarize totals for game wins, match wins, capotes, and bandeiras (optionally segmented by variant)
- **Global Leaderboards**: Visible to all users including anonymous visitors; highlight top players by game and match wins, may include capotes and bandeiras
- **Tie-Breaking**: Earlier achievers rank higher in case of ties
### 5. Administration
#### Administrator Capabilities
- **Profile Management**: Same as regular users, except cannot delete their own accounts
- **Account Management**: Create new administrator accounts, remove any account except their own
- **Soft Deletion**: Player accounts with prior activity must be soft-deleted
- **User Monitoring**: View all users (players and administrators), block/unblock players
- **Read-Only Access**:
- All transactions
- All multiplayer games and matches
- Platform usage summaries and statistics
#### Administrator Access Control
- Cannot play games or hold coins
- New administrator accounts can only be created by existing administrators
### 6. Statistics and Reporting
#### Anonymous Users and Players
- Access only generic, anonymized aggregates:
- Total registered players
- Games and matches played
- Recent activity summaries
#### Administrators
- Full, non-anonymized access including:
- Purchases by period and player
- Game/match volumes
- User activity breakdowns
- Time-series data
#### Visualization
- Statistics available in both visual (charts) and textual/tabular forms
- Privacy for non-admin viewers is preserved
- Exact metrics and visualizations are team-defined
## Enhancement and Innovation Opportunities
To distinguish this project, consider implementing one or more of the following:
### Custom Features (Examples)
- Support for three or more players per game (optional extension while preserving two-player mode)
- Spectator mode for multiplayer games and matches
- Full playback of past games
- Custom card sets
- Extended bot capabilities (e.g., improved AI strategies)
- Integration of bots into multiplayer games
### Architecture and Performance Enhancements (Examples)
- Queue server or worker for asynchronous, long-running operations
- Horizontal scaling of the WebSocket server
- Session recovery after WebSocket or node failures
- Cache server implementation
- NoSQL database for specific use cases
- Search engine for game history or statistics
- Asynchronous messaging broker (e.g., Kafka, RabbitMQ)
- Distributed components for improved scalability and resilience
### Implementation Quality
- Use of technologies or techniques not covered in standard coursework
- Performance optimization with empirical benchmarks
- Improved architecture and code structure
- Enhanced implementation quality and documentation
**Note**: Credit is proportional to demonstrated impact with preference given to distributed capabilities that improve architecture, scalability, or resilience.
## Technology Stack
### Frontend
- Vue.js (mandatory)
- Vite (build tool)
- ESLint (code quality)
### Backend
- **API Server**: Open-source, student-selected technology
- **WebSocket Server**: Open-source, student-selected technology
- **Database**: Open-source, student-selected technology
- All must be compatible with the designated school server
### Supported Variants
- Laravel (PHP) for REST API
- Node.js for WebSocket server
## Project Structure
```
DADProject/
├── api/ # Laravel REST API backend
├── frontend/ # Vue.js SPA
├── websockets/ # WebSocket server
└── README.md # This file
```
## Getting Started
Refer to the individual `README.md` files in each directory for setup and deployment instructions:
- [API Documentation](./api/README.md)
- [Frontend Documentation](./frontend/README.md)
- [WebSocket Server Documentation](./websockets/README.md)
## Database Schema
The application's database includes the following primary entities:
- **Users**: Player and administrator accounts
- **Games**: Individual game records (both single-player and multiplayer)
- **Matches**: Match records (series of games)
- **Coin Transactions**: Purchase and spending history
- **Coin Transaction Types**: Transaction categorization
- **Coin Purchases**: External purchase records
- **Leaderboard Data**: Aggregated player statistics
For detailed schema information, refer to the database migrations in the `api/database/migrations/` directory.
## Key Business Rules
1. **Coin System**:
- New users receive 10 welcome coins
- Conversion rate: €1 = 10 coins
- Coin purchases are made in €1 increments
- All transactions are logged and immutable (except soft-deleted accounts)
2. **Game Rules**:
- Two-player games only (in standard mode)
- Bot cannot be played in multiplayer
- 20-second move timer in multiplayer
- Resignation forfeits remaining games in a match
3. **Account Management**:
- Administrators cannot be created via public registration
- Administrators cannot delete their own accounts
- Account deletion requires explicit confirmation
- Soft deletion preserves historical data for deleted player accounts
4. **Leaderboard Ranking**:
- Multiplayer games and matches only
- Ties resolved by earlier achievement date
## Notes for Developers
- The WebSocket server acts as the authoritative source for all game state in multiplayer games
- Ensure proper error handling and recovery for WebSocket disconnections
- All coin transactions must be atomic and immutable
- Database must be seeded with realistic, varied data
- Privacy and data protection must be maintained throughout
## License
This project is part of the EI DAD 2025/26 course.
+18
View File
@@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[compose.yaml]
indent_size = 4
+65
View File
@@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
# PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
+11
View File
@@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
+26
View File
@@ -0,0 +1,26 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db
composer.lock
+59
View File
@@ -0,0 +1,59 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
### Premium Partners
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\RegisterRequest;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required',
]);
if (! Auth::attempt($request->only('email', 'password'))) {
throw ValidationException::withMessages([
'email' => ['The provided credentials are incorrect.'],
]);
}
$user = Auth::user();
if ($user->blocked) {
Auth::logout();
return response()->json(['message' => 'Your account is blocked. Please contact support.'], 403);
}
$token = $user->createToken('auth-token')->plainTextToken;
return response()->json([
'user' => $user,
'token' => $token,
]);
}
public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();
return response()->json([
'message' => 'Logged out successfully',
]);
}
public function register(RegisterRequest $request)
{
if (User::where('email', $request->email)->exists()) {
return response()->json(['message' => 'Email already registered'], 409);
}
if (User::where('nickname', $request->nickname)->exists()) {
return response()->json(['message' => 'Nickname already registered'], 409);
}
$avatarFilename = null;
if ($request->hasFile('photo_avatar_filename')) {
$file = $request->file('photo_avatar_filename');
$path = $file->store('photos_avatars', 'public');
$avatarFilename = basename($path);
}
$user = User::create([
'email' => $request->email,
'nickname' => $request->nickname,
'name' => $request->name,
'password' => bcrypt($request->password),
'photo_avatar_filename' => $avatarFilename,
'type' => 'P',
'blocked' => false,
'coins_balance' => 10,
]);
$token = $user->createToken('auth-token')->plainTextToken;
return response()->json([
'message' => 'User registered successfully',
'user' => $user,
'token' => $token,
], 201);
}
}
@@ -0,0 +1,76 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\CoinPurchase;
use App\Models\CoinTransaction;
use App\Models\CoinTransactionType;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CoinPurchaseController extends Controller
{
public function store(Request $request)
{
$validated = $request->validate([
'euros' => 'required|numeric|min:1|max:100',
'payment_type' => 'required|in:MBWAY,MB,VISA,PAYPAL',
'payment_reference' => [
'required',
function ($attribute, $value, $fail) use ($request) {
$type = $request->payment_type;
$regex = null;
switch ($type) {
case 'MBWAY': $regex = '/^9[0-9]{8}$/'; break;
case 'MB': $regex = '/^[0-9]{5}-[0-9]{9}$/'; break;
case 'VISA': $regex = '/^4[0-9]{15}$/'; break;
case 'PAYPAL':
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$fail("Invalid PayPal email.");
}
return;
}
if ($regex && !preg_match($regex, $value)) {
$fail("Invalid format for $type.");
}
},
],
]);
$user = $request->user();
$coinsAmount = $validated['euros'] * 10;
return DB::transaction(function () use ($user, $validated, $coinsAmount) {
$type = CoinTransactionType::firstOrCreate(['name' => 'Coin purchase'], ['type' => 'C']);
$transaction = CoinTransaction::create([
'user_id' => $user->id,
'coin_transaction_type_id' => $type->id,
'transaction_datetime' => now(),
'coins' => $coinsAmount,
]);
$purchase = CoinPurchase::create([
'purchase_datetime' => now(),
'user_id' => $user->id,
'coin_transaction_id' => $transaction->id,
'euros' => $validated['euros'],
'payment_type' => $validated['payment_type'],
'payment_reference' => $validated['payment_reference'],
]);
$user->increment('coins_balance', $coinsAmount);
return response()->json([
'message' => 'Purchase successful',
'balance' => $user->coins_balance,
'transaction_id' => $transaction->id,
'purchase' => $purchase,
], 201);
});
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller as BaseController;
abstract class Controller extends BaseController
{
use AuthorizesRequests;
}
+178
View File
@@ -0,0 +1,178 @@
<?php
namespace App\Http\Controllers;
use App\Models\Game;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class GameController extends Controller
{
const GHOST_ID = 1;
public function index(Request $request)
{
$this->authorize('viewAny', Game::class);
$user = Auth::user();
$query = Game::query()->with(["winner", "player1", "player2"]);
// Filter games based on user type
if ($user->type !== 'A') {
// Players can only see games they participate in
$query->where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
});
}
// Admins see all games (no filter needed)
if ($request->has("type") && in_array($request->type, ["3", "9"])) {
$query->where("type", $request->type);
}
if (
$request->has("status") &&
in_array($request->status, [
"Pending",
"Playing",
"Ended",
"Interrupted",
])
) {
$query->where("status", $request->status);
}
if ($request->has("sort_direction") && in_array($request->sort_direction, ["asc", "desc"])) {
$query->orderBy("began_at", $request->sort_direction);
}else{
$query->orderBy("began_at", "desc");
}
return response()->json($query->paginate(15));
}
public function store(Request $request)
{
$this->authorize('create', Game::class);
$validated = $request->validate([
"type" => "required|in:3,9",
]);
$user = Auth::user();
$activeGame = Game::where(function ($q) use ($user) {
$q->where("player1_user_id", $user->id)
->orWhere("player2_user_id", $user->id);
})
->whereIn("status", ["Pending", "Playing"])
->exists();
if ($activeGame) {
return response()->json(["message" => "You already have an active game."], 400);
}
$game = Game::create([
"type" => $validated["type"],
"status" => "Pending",
"player1_user_id" => $user->id,
"player2_user_id" => self::GHOST_ID,
"winner_user_id" => self::GHOST_ID,
"loser_user_id" => self::GHOST_ID,
"began_at" => now(),
"player1_points" => 0,
"player2_points" => 0,
"custom" => null,
]);
return response()->json([
"message" => "Multiplayer game room created",
"game" => $game,
], 201);
}
public function join(Game $game)
{
$this->authorize('join', $game);
$user = Auth::user();
if ($game->player1_user_id == $user->id) {
return response()->json([
"message" => "You are the host. Waiting for opponent...",
"game" => $game
], 200);
}
if ($game->player2_user_id !== self::GHOST_ID) {
return response()->json(["message" => "Game is full"], 400);
}
$game->update([
"status" => "Playing",
"player2_user_id" => $user->id,
]);
return response()->json([
"message" => "Joined successfully!",
"game" => $game,
], 200);
}
public function show(Game $game)
{
$this->authorize('view', $game);
$game->load(["player1", "player2", "winner"]);
return response()->json($game);
}
public function update(Request $request, Game $game)
{
$this->authorize('update', $game);
if ($game->status == "Ended") {
return response()->json(["message" => "Game already ended"], 400);
}
$data = $request->validate([
"status" => "in:Playing,Ended,Interrupted",
"winner_user_id" => "exists:users,id",
"loser_user_id" => "exists:users,id",
"player1_points" => "integer",
"player2_points" => "integer",
"is_draw" => "boolean",
"total_time" => "numeric",
]);
if (isset($data["status"]) && $data["status"] === "Ended") {
$data["ended_at"] = now();
}
$game->update($data);
return response()->json($game);
}
public function resign(Game $game)
{
$this->authorize('resign', $game);
$user = Auth::user();
$game->update([
'status' => 'Ended',
'winner_user_id' => $game->player1_user_id === $user->id
? $game->player2_user_id
: $game->player1_user_id,
'loser_user_id' => $user->id,
'ended_at' => now(),
]);
return response()->json([
'message' => 'You have resigned from the game',
'game' => $game->fresh(),
]);
}
}
@@ -0,0 +1,199 @@
<?php
namespace App\Http\Controllers;
use App\Models\MatchGame;
use App\Models\Game;
use App\Models\CoinTransaction;
use App\Models\CoinTransactionType;
use Illuminate\Http\Request;
use App\Http\Requests\StoreMatchRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class MatchController extends Controller
{
public function index(Request $request)
{
$query = MatchGame::query()->with(['winner', 'player1', 'player2']);
if ($request->has('type')) {
$query->where('type', $request->type);
}
if ($request->has('status')) {
$query->where('status', $request->status);
}
$query->orderBy('began_at', 'desc');
return response()->json($query->paginate(15));
}
public function store(StoreMatchRequest $request)
{
$validated = $request->validated();
$user = $request->user();
$stake = $validated['stake'];
if ($user->coins_balance < $stake) {
return response()->json(['message' => 'Insufficient coin balance'], 400);
}
$activeMatch = MatchGame::where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
})->whereIn('status', ['Pending', 'Playing'])->exists();
if ($activeMatch) {
return response()->json(['message' => 'You already have an active match.'], 400);
}
return DB::transaction(function () use ($validated, $user, $stake) {
$GHOST_ID = 1;
$user->decrement('coins_balance', $stake);
$stakeType = CoinTransactionType::firstOrCreate(
['name' => 'Match stake'],
['type' => 'D'] // Debit
);
$match = MatchGame::create([
'type' => $validated['type'],
'status' => 'Pending',
'player1_user_id' => $user->id,
'player2_user_id' => $GHOST_ID,
'winner_user_id' => $GHOST_ID,
'loser_user_id' => $GHOST_ID,
'stake' => $stake,
'began_at' => now(),
'player1_marks' => 0, 'player2_marks' => 0,
'player1_points' => 0, 'player2_points' => 0,
]);
CoinTransaction::create([
'user_id' => $user->id,
'match_id' => $match->id,
'coin_transaction_type_id' => $stakeType->id,
'transaction_datetime' => now(),
'coins' => -$stake,
]);
return response()->json([
'message' => 'Match created successfully',
'match' => $match,
'balance' => $user->coins_balance
], 201);
});
}
public function show(MatchGame $match)
{
$match->load(['player1', 'player2', 'winner']);
return response()->json($match);
}
public function join(MatchGame $match)
{
$user = request()->user();
if ($match->player1_user_id == $user->id) {
return response()->json(['message' => 'You cannot join your own match'], 400);
}
if ($match->status !== 'Pending') {
return response()->json(['message' => 'Match is full or started'], 400);
}
if ($user->coins_balance < $match->stake) {
return response()->json(['message' => 'Insufficient coin balance to join this match'], 400);
}
$activeMatch = MatchGame::where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
})->whereIn('status', ['Pending', 'Playing'])->exists();
if ($activeMatch) {
return response()->json(['message' => 'You are already in another active match.'], 400);
}
return DB::transaction(function () use ($match, $user) {
$user->decrement('coins_balance', $match->stake);
$stakeType = CoinTransactionType::firstOrCreate(
['name' => 'Match stake'],
['type' => 'D']
);
CoinTransaction::create([
'user_id' => $user->id,
'match_id' => $match->id,
'coin_transaction_type_id' => $stakeType->id,
'transaction_datetime' => now(),
'coins' => -$match->stake,
]);
$match->update([
'status' => 'Playing',
'player2_user_id' => $user->id
]);
return response()->json([
'message' => 'Joined match successfully!',
'match' => $match,
'balance' => $user->coins_balance
]);
});
}
public function update(Request $request, MatchGame $match)
{
if ($match->status == 'Ended') {
return response()->json(['message' => 'Match already ended'], 400);
}
$data = $request->validate([
'status' => 'in:Playing,Ended,Interrupted',
'winner_user_id' => 'exists:users,id',
'loser_user_id' => 'exists:users,id',
'player1_marks' => 'integer',
'player2_marks' => 'integer',
'player1_points' => 'integer',
'player2_points' => 'integer',
'total_time' => 'numeric'
]);
return DB::transaction(function () use ($match, $data) {
if (isset($data['status']) && $data['status'] === 'Ended') {
$data['ended_at'] = now();
}
$match->update($data);
if ($match->status === 'Ended' && $match->stake > 0 && $match->winner_user_id) {
$payoutType = CoinTransactionType::firstOrCreate(
['name' => 'Match payout'],
['type' => 'C'] // Credit
);
$totalPrize = $match->stake * 2;
CoinTransaction::create([
'user_id' => $match->winner_user_id,
'match_id' => $match->id,
'coin_transaction_type_id' => $payoutType->id,
'transaction_datetime' => now(),
'coins' => $totalPrize,
]);
$match->winner->increment('coins_balance', $totalPrize);
}
return response()->json($match);
});
}
}
@@ -0,0 +1,113 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class ProfileController extends Controller
{
public function show(Request $request)
{
$user = $request->user();
return response()->json($user);
}
public function update(Request $request)
{
$request->validate([
"name" => "required|string|max:255",
"nickname" =>
"required|string|max:255|unique:users,nickname," .
$request->user()->id,
]);
$user = $request->user();
$user->name = $request->name;
$user->nickname = $request->nickname;
$user->save();
return response()->json($user);
}
public function destroy(User $user)
{
$currentUser = Auth::user();
if ($currentUser->id !== $user->id && $currentUser->type !== "A") {
return response()->json(["message" => "Unauthorized"], 403);
}
$user->delete();
return response()->json(["message" => "User deleted successfully"]);
}
public function updatePassword(Request $request)
{
$request->validate([
"current_password" => "required",
"new_password" => "required|min:8|confirmed",
]);
$user = $request->user();
if (!Hash::check($request->current_password, $user->password)) {
return response()->json(
[
"message" => "Current password is incorrect",
],
422,
);
}
$user->password = Hash::make($request->new_password);
$user->save();
return response()->json([
"message" => "Password changed successfully",
]);
}
public function getCoins(Request $request)
{
return response()->json([
'coins' => $request->user()->coins_balance
]);
}
public function updateAvatar(Request $request)
{
$request->validate([
"avatar" => "required|image|mimes:jpeg,png,jpg,gif|max:2048",
]);
$user = $request->user();
if ($user->photo_avatar_filename) {
Storage::disk("public")->delete(
"photos_avatars/" . $user->photo_avatar_filename,
);
}
$file = $request->file("avatar");
$filename =
str_pad($user->id, 5, "0", STR_PAD_LEFT) .
"_" .
Str::random(10) .
"." .
$file->extension();
$file->storeAs("photos_avatars", $filename, "public");
$user->photo_avatar_filename = $filename;
$user->save();
return response()->json($user);
}
}
@@ -0,0 +1,136 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Game;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\CoinTransaction;
class StatisticsController extends Controller
{
public function getPublicStats()
{
$totalPlayers = User::where('type', 'P')->count();
$totalGames = Game::where('status', 'Ended')->count();
$activeGames = Game::where('status', 'Playing')->count();
return response()->json([
'total_players' => $totalPlayers,
'total_games' => $totalGames,
'active_games' => $activeGames,
]);
}
public function getLeaderboard(Request $request)
{
$type = $request->query('type');
$leaderboard = User::where('type', 'P')
->withCount(['wonGames' => function ($query) use ($type) {
if ($type) {
$query->where('type', $type);
}
}])
->orderBy('won_games_count', 'desc')
->paginate(10);
$leaderboard->through(function ($user) {
return [
'id' => $user->id,
'nickname' => $user->nickname,
'photo_avatar_filename' => $user->photo_avatar_filename,
'won_games_count' => $user->won_games_count,
];
});
return response()->json($leaderboard);
}
public function getPersonalStats(Request $request)
{
$user = $request->user();
$totalGames = Game::where('status', 'Ended')
->where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
})
->count();
$totalWins = Game::where('status', 'Ended')
->where('winner_user_id', $user->id)
->count();
$totalLosses = $totalGames - $totalWins; // Simplest math
$winRate = 0;
if ($totalGames > 0) {
$winRate = round(($totalWins / $totalGames) * 100, 1);
}
return response()->json([
'nickname' => $user->nickname,
'total_games' => $totalGames,
'total_wins' => $totalWins,
'total_losses' => $totalLosses,
'win_rate' => $winRate . '%',
'current_balance' => $user->coins_balance, // Extra info
]);
}
public function getAdminStats()
{
$totalPlayers = User::where('type', 'P')->count();
$totalGames = Game::count();
$totalBlockedUsers = User::where('blocked', true)->count();
$gamesByType = Game::select('type', DB::raw('count(*) as total'))
->groupBy('type')
->get();
$gamesPerMonth = Game::select(
DB::raw("strftime('%Y-%m', began_at) as month"),
DB::raw('count(*) as total')
)
->whereNotNull('began_at')
->groupBy('month')
->orderBy('month', 'desc')
->limit(12)
->get();
$totalCoinsPurchased = \App\Models\CoinTransaction::whereHas('type', function($q) {
$q->where('name', 'Coin purchase');
})
->sum('coins');
$purchasesPerMonth = \App\Models\CoinTransaction::join('coin_transaction_types', 'coin_transactions.coin_transaction_type_id', '=', 'coin_transaction_types.id')
->where('coin_transaction_types.name', 'Coin purchase')
->select(
DB::raw("strftime('%Y-%m', coin_transactions.transaction_datetime) as month"),
DB::raw('SUM(coin_transactions.coins) as total_coins')
)
->groupBy('month')
->orderBy('month', 'desc')
->limit(12)
->get();
return response()->json([
'global_counters' => [
'total_players' => $totalPlayers,
'total_games' => $totalGames,
'blocked_users' => $totalBlockedUsers,
'total_coins_purchased' => (int) $totalCoinsPurchased,
],
'charts' => [
'games_by_type' => $gamesByType,
'games_per_month' => $gamesPerMonth,
'purchases_per_month' => $purchasesPerMonth,
]
]);
}
}
+304
View File
@@ -0,0 +1,304 @@
<?php
namespace App\Http\Controllers;
use App\Models\Game;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rule;
class UserController extends Controller
{
/**
* GET /api/users
* Lista todos os utilizadores (Apenas para Admins)
*/
public function index(Request $request)
{
$this->authorize('viewAny', User::class);
$query = User::query();
// Filtros úteis para o Backoffice
if ($request->has('type')) {
$query->where('type', $request->type);
}
if ($request->has('search')) {
$query->where(function ($q) use ($request) {
$q->where('name', 'like', '%'.$request->search.'%')
->orWhere('email', 'like', '%'.$request->search.'%')
->orWhere('nickname', 'like', '%'.$request->search.'%');
});
}
return response()->json($query->paginate(15));
}
/**
* POST /api/users
* Registar um novo utilizador (Admin only)
*/
public function store(Request $request)
{
$this->authorize('create', User::class);
$validated = $request->validate([
'name' => 'required|string|max:255',
'nickname' => 'required|string|max:20|unique:users,nickname',
'email' => 'required|email|unique:users,email',
'password' => 'required|string|min:3',
'type' => 'required|in:A,U',
]);
$validated['password'] = Hash::make($validated['password']);
$user = User::create($validated);
return response()->json($user, 201);
}
/**
* GET /api/users/me
* Retorna o perfil do utilizador autenticado atual.
* Usado pelo VueJS para saber quem está logado.
*/
public function me(Request $request)
{
return response()->json($request->user());
}
/**
* GET /api/users/{user}
* Mostra um perfil específico.
*/
public function show(User $user)
{
$currentUser = Auth::user();
// Admins and owners get full profile, others get limited view
if ($currentUser->type === 'A' || $currentUser->id === $user->id) {
return response()->json($user);
} else {
return response()->json([
'id' => $user->id,
'name' => $user->name,
'nickname' => $user->nickname,
'photo_avatar_filename' => $user->photo_avatar_filename,
'type' => $user->type,
]);
}
}
/**
* PUT/PATCH /api/users/{user}
* Atualizar perfil (Nome, Nickname, Password, Foto)
*/
public function update(Request $request, User $user)
{
$this->authorize('update', $user);
$validated = $request->validate([
'name' => 'sometimes|string|max:255',
'nickname' => [
'sometimes',
'string',
'max:20',
Rule::unique('users')->ignore($user->id),
],
'email' => [
'sometimes',
'email',
Rule::unique('users')->ignore($user->id),
],
'password' => 'sometimes|string|min:3',
]);
// Lógica de Upload de Foto (Exemplo Básico)
// if ($request->hasFile('photo_avatar')) {
// $path = $request->file('photo_avatar')->store('avatars', 'public');
// $validated['photo_avatar_filename'] = basename($path);
// }
$user->update($validated);
return response()->json($user);
}
public function updatePassword(Request $request, User $user)
{
$this->authorize('update', $user);
$validated = $request->validate([
'current_password' => 'required|string',
'new_password' => 'required|string|min:3|confirmed',
]);
// Verificar se a password atual está correta
if (!Hash::check($validated['current_password'], $user->password)) {
return response()->json(['message' => 'Current password is incorrect'], 403);
}
// Atualizar para a nova password
$user->password = Hash::make($validated['new_password']);
$user->save();
return response()->json(['message' => 'Password updated successfully']);
}
/**
* DELETE /api/users/{user}
* Apagar conta (Soft Delete)
*/
public function destroy(User $user)
{
$this->authorize('delete', $user);
// Check if user has transactions or games - if so, soft delete
$hasTransactions = $user->transactions()->exists();
$hasGames = Game::where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
})->exists();
if ($hasTransactions || $hasGames) {
$user->delete(); // Soft delete
$message = 'User account deactivated (soft-deleted due to transaction/game history)';
} else {
$user->forceDelete(); // Hard delete
$message = 'User permanently deleted';
}
return response()->json(['message' => $message]);
}
/**
* GET /api/users/{user}/matches
* Histórico de Jogos Multiplayer do Utilizador
*/
public function getMatches(Request $request, User $user)
{
$this->authorize('view', $user);
$outcomeSql = "CASE
WHEN is_draw = 1 THEN 'DRAW'
WHEN winner_user_id = {$user->id} THEN 'WIN'
ELSE 'LOSS'
END";
$query = Game::query()
->select('*')
->selectRaw("($outcomeSql) as outcome_text")
->where(function ($q) use ($user) {
$q->where('player1_user_id', $user->id)
->orWhere('player2_user_id', $user->id);
})
->with(['winner', 'player1', 'player2']);
if ($request->has('type')) {
$query->where('type', $request->type);
}
if ($request->has('status')) {
$query->where('status', $request->status);
}
if ($request->filled('outcome')) {
switch ($request->outcome) {
case 'win':
$query->where('winner_user_id', $user->id)
->where('is_draw', 0);
break;
case 'loss':
case 'forfeit': // Forfeit treated as loss for now
$query->where('loser_user_id', $user->id)
->where('is_draw', 0);
break;
case 'draw':
$query->where('is_draw', 1);
break;
}
}
if ($request->has('date_from')) {
$query->whereDate('began_at', '>=', $request->date_from);
}
if ($request->has('date_to')) {
$query->whereDate('ended_at', '<=', $request->date_to);
}
$order = $request->get('sort_by', 'began_at');
$direction = $request->get('sort_direction', 'desc');
if ($order === 'outcome') {
$query->orderBy('outcome_text', $direction);
} else {
$query->orderBy($order, $direction);
}
$matches = $query->orderBy($order, $direction)
->paginate(10);
return response()->json($matches);
}
public function block(User $user)
{
$this->authorize('block', $user);
$user->blocked = true;
$user->save();
// Revoke all active tokens for immediate effect
$user->tokens()->delete();
return response()->json(['message' => 'User blocked successfully']);
}
public function unblock(User $user)
{
$this->authorize('unblock', $user);
$user->blocked = false;
$user->save();
return response()->json(['message' => 'User unblocked successfully']);
}
public function getTransactions(Request $request, User $user)
{
if ($request->user()->id !== $user->id && $request->user()->type !== 'A') {
return response()->json(['message' => 'Forbidden'], 403);
}
$query = $user->transactions()->with('type');
if ($request->has('type')) {
$query->whereHas('type', function ($q) use ($request) {
$q->where('type', $request->type);
});
}
if ($request->has('date_from')) {
$query->whereDate('transaction_datetime', '>=', $request->date_from);
}
if ($request->has('date_to')) {
$query->whereDate('transaction_datetime', '<=', $request->date_to);
}
$transactions = $query->orderBy('transaction_datetime', 'desc')
->paginate(10);
return response()->json($transactions);
}
public function getMyTransactions(Request $request)
{
return $this->getTransactions($request, $request->user());
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class CheckUserType
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(
Request $request,
Closure $next,
string $type,
): Response {
$user = $request->user();
if (!$user || $user->type !== $type) {
return response()->json(
["message" => "Unauthorized. User type {$type} required."],
403,
);
}
return $next($request);
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => 'required|email|unique:users,email',
'nickname' => 'required|string|max:255',
'name' => 'required|string|max:255',
'password' => 'required|string|min:3',
'photo' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
];
}
}
@@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreGameRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
// Só utilizadores autenticados podem criar jogos
return Auth::check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
// Agora validamos diretamente '3' ou '9' para bater certo com a BD
'type' => 'required|in:3,9',
];
}
/**
* Mensagens personalizadas (Opcional)
*/
public function messages(): array
{
return [
'type.required' => 'You must choose a game type (Bisca de 3 or 9).',
'type.in' => 'Invalid game type. Choose 3 or 9.',
];
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreMatchRequest extends FormRequest
{
public function authorize(): bool
{
return Auth::check();
}
public function rules(): array
{
return [
'type' => 'required|in:3,9',
'stake' => 'required|integer|min:1',
];
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CoinPurchase extends Model
{
use HasFactory;
protected $table = 'coin_purchases';
public $timestamps = false;
protected $fillable = [
'purchase_datetime',
'user_id',
'coin_transaction_id',
'euros',
'payment_type',
'payment_reference',
'custom'
];
protected $casts = [
'purchase_datetime' => 'datetime',
'custom' => 'array',
];
public function transaction()
{
return $this->belongsTo(CoinTransaction::class, 'coin_transaction_id');
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CoinTransaction extends Model
{
use HasFactory;
protected $table = 'coin_transactions';
public $timestamps = false;
protected $fillable = [
'transaction_datetime',
'user_id',
'match_id',
'game_id',
'coin_transaction_type_id',
'coins',
'custom'
];
protected $casts = [
'transaction_datetime' => 'datetime',
'custom' => 'array',
];
public function type()
{
return $this->belongsTo(CoinTransactionType::class, 'coin_transaction_type_id');
}
public function user()
{
return $this->belongsTo(User::class);
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class CoinTransactionType extends Model
{
use HasFactory, SoftDeletes;
protected $table = 'coin_transaction_types';
protected $fillable = ['name', 'type', 'custom'];
protected $casts = [
'custom' => 'array',
];
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Game extends Model
{
use HasFactory;
public $timestamps = false;
protected $fillable = [
'type',
'status',
'player1_user_id',
'player2_user_id',
'winner_user_id',
'loser_user_id',
'began_at',
'ended_at',
'total_time',
'player1_points',
'player2_points',
'custom',
'is_draw',
'match_id'
];
public function winner()
{
return $this->belongsTo(User::class, "winner_user_id");
}
public function player1()
{
return $this->belongsTo(User::class, 'player1_user_id');
}
public function player2()
{
return $this->belongsTo(User::class, 'player2_user_id');
}
}
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MatchGame extends Model
{
use HasFactory;
protected $table = 'matches';
public $timestamps = false;
protected $fillable = [
'type',
'status',
'player1_user_id',
'player2_user_id',
'winner_user_id',
'loser_user_id',
'began_at',
'ended_at',
'total_time',
'player1_marks',
'player2_marks',
'player1_points',
'player2_points',
'stake',
'custom'
];
protected $casts = [
'began_at' => 'datetime',
'ended_at' => 'datetime',
'player1_marks' => 'integer',
'player2_marks' => 'integer',
'player1_points' => 'integer',
'player2_points' => 'integer',
'stake' => 'integer',
];
public function player1()
{
return $this->belongsTo(User::class, 'player1_user_id');
}
public function player2()
{
return $this->belongsTo(User::class, 'player2_user_id');
}
public function winner()
{
return $this->belongsTo(User::class, 'winner_user_id');
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'nickname',
'type',
'photo_avatar_filename',
'coins_balance',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'blocked' => 'boolean',
'deleted_at' => 'datetime',
];
public function wonGames()
{
return $this->hasMany(Game::class, 'winner_user_id');
}
public function games()
{
return $this->hasMany(Game::class, 'player1_user_id')->orWhere('player2_user_id', $this->id);
}
public function transactions()
{
return $this->hasMany(CoinTransaction::class);
}
}
+134
View File
@@ -0,0 +1,134 @@
<?php
namespace App\Policies;
use App\Models\Game;
use App\Models\User;
class GamePolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return true;
}
/**2
* Determine whether the user can view the model.
*/
public function view(User $user, Game $game): bool
{
if ($user->type === "A") {
return true;
}
if (
$game->player1_user_id === $user->id ||
$game->player2_user_id === $user->id
) {
return true;
}
if ($game->status === "Pending") {
return true;
}
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
if ($user->type === "A") {
return false;
}
return true;
}
public function join(User $user, Game $game): bool
{
if ($user->type === "A") {
return false;
}
if (
$game->status !== "Pending" ||
$game->player1_user_id === $user->id
) {
return false;
}
if ($game->player2_user_id !== null && $game->player2_user_id !== 1) {
return false;
}
return true;
}
public function resign(User $user, Game $game): bool
{
if ($user->type === "A") {
return false;
}
if (
$game->status !== "Playing" ||
($game->player1_user_id !== $user->id &&
$game->player2_user_id !== $user->id)
) {
return false;
}
return true;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Game $game): bool
{
if ($user->type === "A") {
return false;
}
if (
$game->status !== "Playing" ||
($game->player1_user_id !== $user->id &&
$game->player2_user_id !== $user->id)
) {
return false;
}
return true;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Game $game): bool
{
// Only admins can delete games
return $user->type === "A";
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Game $game): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Game $game): bool
{
return false;
}
}
+74
View File
@@ -0,0 +1,74 @@
<?php
namespace App\Policies;
use App\Models\User;
class UserPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->type === 'A';
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, User $model): bool
{
return $user->id === $model->id || $user->type === 'A';
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->type === 'A';
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, User $model): bool
{
return $user->id === $model->id;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, User $model): bool
{
return ($user->type === 'A' && $user->id !== $model->id) || ($user->type === 'P' && $user->id === $model->id);
}
public function block(User $user, User $model): bool
{
return $user->type === 'A' && $user->id !== $model->id && $model->type === 'P';
}
public function unblock(User $user, User $model): bool
{
return $user->type === 'A' && $user->id !== $model->id && $model->type === 'P';
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, User $model): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, User $model): bool
{
return false;
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput);
exit($status);
+22
View File
@@ -0,0 +1,22 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__ . "/../routes/web.php",
api: __DIR__ . "/../routes/api.php",
commands: __DIR__ . "/../routes/console.php",
health: "/up",
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->alias([
"user.type" => App\Http\Middleware\CheckUserType::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
})
->create();
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
Vendored Regular → Executable
+14
View File
@@ -13,6 +13,13 @@
0 => 'Laravel\\Sail\\SailServiceProvider',
),
),
'laravel/sanctum' =>
array (
'providers' =>
array (
0 => 'Laravel\\Sanctum\\SanctumServiceProvider',
),
),
'laravel/tinker' =>
array (
'providers' =>
@@ -41,4 +48,11 @@
0 => 'Termwind\\Laravel\\TermwindServiceProvider',
),
),
'pestphp/pest-plugin-laravel' =>
array (
'providers' =>
array (
0 => 'Pest\\Laravel\\PestServiceProvider',
),
),
);
Vendored Regular → Executable
+16 -9
View File
@@ -26,11 +26,13 @@
22 => 'Illuminate\\View\\ViewServiceProvider',
23 => 'Laravel\\Pail\\PailServiceProvider',
24 => 'Laravel\\Sail\\SailServiceProvider',
25 => 'Laravel\\Tinker\\TinkerServiceProvider',
26 => 'Carbon\\Laravel\\ServiceProvider',
27 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
28 => 'Termwind\\Laravel\\TermwindServiceProvider',
29 => 'App\\Providers\\AppServiceProvider',
25 => 'Laravel\\Sanctum\\SanctumServiceProvider',
26 => 'Laravel\\Tinker\\TinkerServiceProvider',
27 => 'Carbon\\Laravel\\ServiceProvider',
28 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
29 => 'Termwind\\Laravel\\TermwindServiceProvider',
30 => 'Pest\\Laravel\\PestServiceProvider',
31 => 'App\\Providers\\AppServiceProvider',
),
'eager' =>
array (
@@ -45,10 +47,12 @@
8 => 'Illuminate\\Session\\SessionServiceProvider',
9 => 'Illuminate\\View\\ViewServiceProvider',
10 => 'Laravel\\Pail\\PailServiceProvider',
11 => 'Carbon\\Laravel\\ServiceProvider',
12 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
13 => 'Termwind\\Laravel\\TermwindServiceProvider',
14 => 'App\\Providers\\AppServiceProvider',
11 => 'Laravel\\Sanctum\\SanctumServiceProvider',
12 => 'Carbon\\Laravel\\ServiceProvider',
13 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
14 => 'Termwind\\Laravel\\TermwindServiceProvider',
15 => 'Pest\\Laravel\\PestServiceProvider',
16 => 'App\\Providers\\AppServiceProvider',
),
'deferred' =>
array (
@@ -98,12 +102,15 @@
'Illuminate\\Queue\\Console\\ForgetFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ListenCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\MonitorCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\PauseCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\PruneBatchesCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\PruneFailedJobsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RestartCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ResumeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RetryCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RetryBatchCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\WorkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ReloadCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
App\Providers\AppServiceProvider::class,
];
+55
View File
@@ -0,0 +1,55 @@
services:
laravel.test:
build:
context: "./vendor/laravel/sail/runtimes/8.4"
dockerfile: Dockerfile
args:
WWWGROUP: "${WWWGROUP}"
image: "sail-8.4/app"
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "${APP_PORT:-80}:80"
environment:
WWWUSER: "${WWWUSER}"
LARAVEL_SAIL: 1
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
IGNITION_LOCAL_SITES_PATH: "${PWD}"
volumes:
- ".:/var/www/html"
networks:
- sail
depends_on:
- mysql
mysql:
image: "mysql/mysql-server:8.0"
ports:
- "${FORWARD_DB_PORT:-3306}:3306"
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_EXTRA_OPTIONS: "${MYSQL_EXTRA_OPTIONS:-}"
volumes:
- "sail-mysql:/var/lib/mysql"
- "./vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh"
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- "-p${DB_PASSWORD}"
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
+91
View File
@@ -0,0 +1,91 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": [
"laravel",
"framework"
],
"license": "MIT",
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.26",
"laravel/sail": "^1.48",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"pestphp/pest": "^4.1",
"pestphp/pest-plugin-laravel": "^4.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
+126
View File
@@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];
@@ -39,11 +39,6 @@ return [
'serialize' => false,
],
'session' => [
'driver' => 'session',
'key' => env('SESSION_CACHE_KEY', '_cache'),
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
@@ -117,6 +112,6 @@ return [
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_cache_'),
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
];
@@ -36,13 +36,11 @@ return [
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'prefix_indexes' => null,
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
'pragmas' => [],
],
'mysql' => [
@@ -150,7 +148,7 @@ return [
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
@@ -115,23 +115,4 @@ return [
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => env('MAIL_MARKDOWN_THEME', 'default'),
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
@@ -25,7 +25,7 @@ return [
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "failover", "null"
| "deferred", "background", "failover", "null"
|
*/
@@ -77,6 +77,10 @@ return [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
@@ -15,11 +15,11 @@ return [
*/
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_KEY'),
'key' => env('RESEND_API_KEY'),
],
'ses' => [
@@ -129,7 +129,7 @@ return [
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel'), '_').'_session'
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
+1
View File
@@ -0,0 +1 @@
*.sqlite*
Binary file not shown.
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,258 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
// Administrator, Player
$table->enum('type', ['A', 'P'])->default('P');
// Nickname - must be unique
$table->string('nickname', 20)->nullable()->unique();
// User access is blocked
$table->boolean('blocked')->default(false);
// User Photo/Avatar
$table->string('photo_avatar_filename')->nullable();
// Brain Coin Balance
$table->integer('coins_balance')->default(0);
// Users can be deleted with "soft deletes"
$table->softDeletes();
// custom data
$table->json('custom')->nullable();
});
// NOTE: Only multiplayer matches are registered
Schema::create('matches', function (Blueprint $table) {
$table->id();
// Type of games in the match (Bisca dos 3; Bisca dos 9)
$table->enum('type', ['3', '9'])->default('3');
// Player 1 (usually, creates the match)
$table->unsignedBigInteger('player1_user_id');
$table->foreign('player1_user_id')->references('id')->on('users');
// Player 2 (usually, joins the match)
$table->unsignedBigInteger('player2_user_id');
$table->foreign('player2_user_id')->references('id')->on('users');
// Winner (null when not ended)
$table->unsignedBigInteger('winner_user_id')->nullable();
$table->foreign('winner_user_id')->references('id')->on('users');
// Loser (null when not ended)
$table->unsignedBigInteger('loser_user_id')->nullable();
$table->foreign('loser_user_id')->references('id')->on('users');
// Match status
// Pending - Match is waiting for players
// Playing - Match is in progress
// Ended - Match is over
// Interrupted - Match was interrupted due to technical issues (not finished; no winner)
// Note: depending of the project's implementation, some status may never be used
$table->enum('status', ['Pending', 'Playing', 'Ended', 'Interrupted']);
// The stake for this match
$table->integer('stake')->default(3);
// Moment when the match began
$table->dateTime('began_at')->nullable();
// Moment when the match ended
$table->dateTime('ended_at')->nullable();
// Match total time (in seconds) = ended_at - began_at
$table->decimal('total_time', 8, 2)->nullable();
// After the match ended, the total marks for player 1
$table->integer('player1_marks')->nullable();
// After the game ended, the total marks for player 2
$table->integer('player2_marks')->nullable();
// After the match ended, the sum of points for player 1 (all games)
$table->integer('player1_points')->nullable();
// After the match ended, the sum of points for player 2 (all games)
$table->integer('player2_points')->nullable();
// custom data
$table->json('custom')->nullable();
});
// NOTE: Only multiplayer games are registered
Schema::create('games', function (Blueprint $table) {
$table->id();
// Type of game (Bisca dos 3; Bisca dos 9)
$table->enum('type', ['3', '9'])->default('3');
// Player 1 (usually, creates the game)
$table->unsignedBigInteger('player1_user_id');
$table->foreign('player1_user_id')->references('id')->on('users');
// Player 2 (usually, joins the game)
$table->unsignedBigInteger('player2_user_id');
$table->foreign('player2_user_id')->references('id')->on('users');
// True when the game has ended with a draw
$table->boolean('is_draw')->default(false);
// Winner (null when not ended, or when a draw)
$table->unsignedBigInteger('winner_user_id')->nullable();
$table->foreign('winner_user_id')->references('id')->on('users');
// Loser (null when not ended, or when a draw)
$table->unsignedBigInteger('loser_user_id')->nullable();
$table->foreign('loser_user_id')->references('id')->on('users');
// Match (null for standalone games)
$table->unsignedBigInteger('match_id')->nullable();
$table->foreign('match_id')->references('id')->on('matches');
// Game status: 'Pending', 'Playing', 'Ended', or 'Interrupted'.
// Pending: waiting for players
// Playing: in progress
// Ended: finished
// Interrupted: stopped due to technical issues (unfinished; no winner)
// Note: depending on the projects implementation, some statuses may never be used.
$table->enum('status', ['Pending', 'Playing', 'Ended', 'Interrupted']);
// Moment when the game began
$table->dateTime('began_at')->nullable();
// Moment when the game ended
$table->dateTime('ended_at')->nullable();
// Game total time (in seconds) = ended_at - began_at
$table->decimal('total_time', 8, 2)->nullable();
// After the game ended, the total of points for player 1
$table->integer('player1_points')->nullable();
// After the game ended, the total of points for player 2
$table->integer('player2_points')->nullable();
// custom data
$table->json('custom')->nullable();
});
Schema::create('coin_transaction_types', function (Blueprint $table) {
$table->id();
$table->string('name', 40);
// Credit - increase coins
// Debit - decrease coins
$table->enum('type', ['C', 'D']);
// Transaction Types can be deleted with "soft deletes"
$table->softDeletes();
// custom data
$table->json('custom')->nullable();
});
// Add default coin_transaction_types
DB::table('coin_transaction_types')->insert([
['name' => 'Bonus', 'type' => 'C'], // id = 1
['name' => 'Coin purchase', 'type' => 'C'], // id = 2
['name' => 'Game fee', 'type' => 'D'], // id = 3
['name' => 'Match stake', 'type' => 'D'], // id = 4
['name' => 'Game payout', 'type' => 'C'], // id = 5
['name' => 'Match payout', 'type' => 'C'], // id = 6
]);
Schema::create('coin_transactions', function (Blueprint $table) {
$table->id();
// Datetime of the coin transaction
$table->dateTime('transaction_datetime');
// User associated with the transaction
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
// Match associated with the transaction (optional - it can be null)
$table->unsignedBigInteger('match_id')->nullable();
$table->foreign('match_id')->references('id')->on('matches');
// Game associated with the transaction (optional - it can be null)
$table->unsignedBigInteger('game_id')->nullable();
$table->foreign('game_id')->references('id')->on('games');
// Type of the transaction
$table->unsignedBigInteger('coin_transaction_type_id');
$table->foreign('coin_transaction_type_id')->references('id')->on('coin_transaction_types');
// Amount of the transaction (coins)
// Positive -> increments the total amount of brain coins (Credit)
// Negative -> decrements the total amount of brain coins (Debit)
$table->integer('coins');
// custom data
$table->json('custom')->nullable();
});
Schema::create('coin_purchases', function (Blueprint $table) {
$table->id();
// Datetime of the coin purchase
$table->dateTime('purchase_datetime');
// User associated with the purchase
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
// Coin Transaction associated with this purchase
// One to One relation (purchase must have a coin transaction)
$table->unsignedBigInteger('coin_transaction_id')->unique();
$table->foreign('coin_transaction_id')->references('id')->on('coin_transactions');
// Amount of the purchase (real money in euros)
$table->decimal('euros', 8, 2);
// Purchases will involve a payment with a type and a reference
// MBWAY - Phone number with 9 digits
// PAYPAL - eMail
// IBAN - bank transfer (2 letters + 23 digits)
// MB - Multibanco payment - entity number (5 digits) + Reference (9 digits))
// VISA - Visa card number (16 digits)
$table->enum('payment_type', ['MBWAY', 'PAYPAL', 'IBAN', 'MB', 'VISA']);
$table->string('payment_reference', 30);
// custom data
$table->json('custom')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::drop('coin_purchases');
Schema::drop('coin_transactions');
Schema::drop('coin_transaction_types');
Schema::drop('games');
Schema::drop('matches');
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('deleted_at');
$table->dropColumn('custom');
$table->dropColumn('coins_balance');
$table->dropColumn('photo_avatar_filename');
$table->dropColumn('blocked');
$table->dropColumn('nickname');
$table->dropColumn('type');
});
}
};
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
public static $startDate;
public static $dbInsertBlockSize = 500;
// public static $seedType = "small";
//public static $seedType = "full";
//public static $seedLanguage = "pt_PT";
public static $seedLanguage = "en_US";
public function run(): void
{
$this->command->info("-----------------------------------------------");
$this->command->info("START of database seeder");
$this->command->info("-----------------------------------------------");
self::$startDate = Carbon::now()->subMonths(14);
self::$seedLanguage = $this->command->choice('What is the language for users\' names?', ['pt_PT', 'en_US'], 0);
if (DB::getDriverName() === 'sqlite') {
DB::statement('PRAGMA foreign_keys = OFF');
} else {
DB::statement('SET foreign_key_checks=0');
// No permissions to change global setting. Change the session setting only
//DB::statement("SET @@global.time_zone = '+00:00'");
DB::statement("SET time_zone = '+00:00'");
}
DB::table('users')->delete();
DB::table('matches')->delete();
DB::table('games')->delete();
DB::table('coin_purchases')->delete();
DB::table('coin_transactions')->delete();
DB::table('coin_transaction_types')->delete();
if (DB::getDriverName() === 'sqlite') {
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'users'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'matches'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'games'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_purchases'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_transactions'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_transaction_types'");
} else {
DB::statement('ALTER TABLE users AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE matches AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE games AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_purchases AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_transactions AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_transaction_types AUTO_INCREMENT = 0');
}
$this->command->info("-----------------------------------------------");
$this->call(TransactionTypesSeeder::class);
$this->call(UsersSeeder::class);
$this->call(InitialTransactionsSeeder::class);
$this->call(GamesSeeder::class);
$this->call(GamesTransactionsSeeder::class);
if (DB::getDriverName() === 'sqlite') {
DB::statement('PRAGMA foreign_keys = ON');
} else {
DB::statement('SET foreign_key_checks=1');
}
$this->command->info("-----------------------------------------------");
$this->command->info("END of database seeder");
$this->command->info("-----------------------------------------------");
}
}
+214
View File
@@ -0,0 +1,214 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Illuminate\Container\Attributes\Database;
class GamesSeeder extends Seeder
{
private $ratioStandaloneToMatch = 15;
private function calculateRandomSeconds($filteredCollection)
{
$totalPlayers = $filteredCollection->count() + 1;
return (12 * 60 * 60) / $totalPlayers + rand(0, 2000);
}
private function nextGameDateTime(&$d, $filteredPlayers, $withinSameMatch = false) {
if ($withinSameMatch) {
$deltaSegundos = rand(300, 900);
} else {
$deltaSegundos = $this->calculateRandomSeconds($filteredPlayers);
}
$d->addSeconds($deltaSegundos);
}
public function run(): void
{
$this->command->info("Games seeder - Start");
$start = DB::table('users')->where('type', 'P')->min('created_at');
$allPlayers = DB::table('users')->where('type', 'P')->get();
$sortedPlayers = $allPlayers->sortBy('created_at')->values();
$d = new \Carbon\Carbon($start);
$d = $d->addDay();
$now = \Carbon\Carbon::now();
$this->command->info("Starting to create games");
$games = [];
$matches = [];
$i = 0;
$filteredPlayers = null;
$filteredPlayersIds = null;
$nextCreatedAt = null;
while ($d->lte($now)) {
$i++;
if (($filteredPlayers === null) || ($nextCreatedAt === null) ||
($d->gte($nextCreatedAt))
) {
$filteredPlayers = $allPlayers->filter(function ($value) use ($d) {
return $d->gt($value->created_at);
});
$nextCreatedAtPlayer = $sortedPlayers->first(function ($value) use ($d) {
return $d->lte($value->created_at);
});
$nextCreatedAt = $nextCreatedAtPlayer ? $nextCreatedAtPlayer->created_at : new \Carbon\Carbon('9999-12-31');
$filteredPlayersIds = $filteredPlayers->pluck('id')->toArray();
}
// Only creates games or matches when there are enough players
if ($filteredPlayersIds === null || empty($filteredPlayersIds) || count($filteredPlayersIds) <2) {
$this->nextGameDateTime($d, $filteredPlayers);
continue;
}
$userIdKeys = array_rand($filteredPlayersIds, 2);
$userIDPlayer1 = $filteredPlayersIds[$userIdKeys[0]];
$userIDPlayer2 = $filteredPlayersIds[$userIdKeys[1]];
if ($userIDPlayer1 == $userIDPlayer2) {
$this->nextGameDateTime($d, $filteredPlayers);
continue;
}
$match = null;
if (rand(1, $this->ratioStandaloneToMatch) === 1) {
$match = $this->newMatch($filteredPlayers, $userIDPlayer1, $userIDPlayer2, $d);
$playersMarks = [0, 0];
$playersPoints = [0, 0];
while($playersMarks[0] < 4 && $playersMarks[1] <4) {
$newGame = $this->newGame($filteredPlayers, $match, $userIDPlayer1, $userIDPlayer2, $d);
$games[] = $newGame;
$playersPoints[0] += $newGame['player1_points'];
$playersPoints[1] += $newGame['player2_points'];
if ($newGame['player1_points'] > $newGame['player2_points']) {
if ($newGame['player1_points'] >= 120) {
$playersMarks[0]+= 4;
} elseif ($newGame['player1_points'] >= 91) {
$playersMarks[0] += 2;
} else {
$playersMarks[0]++;
}
} elseif ($newGame['player2_points'] > $newGame['player1_points']) {
if ($newGame['player2_points'] >= 120) {
$playersMarks[1]+= 4;
} elseif ($newGame['player2_points'] >= 91) {
$playersMarks[1] += 2;
} else {
$playersMarks[1]++;
}
}
}
$this->updateMatchWinner($match, $playersMarks[0], $playersMarks[1], $playersPoints[0], $playersPoints[1], $d);
$matches[] = $match;
} else {
$newGame = $this->newGame($filteredPlayers, $match, $userIDPlayer1, $userIDPlayer2, $d);
$games[] = $newGame;
}
if ($i >= DatabaseSeeder::$dbInsertBlockSize) {
if (!empty($matches)) {
DB::table('matches')->insert($matches);
$this->command->info("Saved " . count($matches) . " matches at date " . $d->format('Y-m-d H:i:s'));
}
if (!empty($games)) {
DB::table('games')->insert($games);
$this->command->info("Saved " . count($games) . " games at date " . $d->format('Y-m-d H:i:s'));
}
$i = 0;
$games = [];
$matches = [];
}
//$this->nextGameDateTime($d, $filteredPlayers);
}
if (!empty($matches)) {
DB::table('matches')->insert($matches);
$this->command->info("Saved " . count($matches) . " matches at date " . $d->format('Y-m-d H:i:s'));
}
if (!empty($games)) {
DB::table('games')->insert($games);
$this->command->info("Saved " . count($games) . " games at date " . $d->format('Y-m-d H:i:s'));
}
$this->command->info("Games seeder - End");
}
private $matchID = 0;
private function newMatch($filteredPlayers,$user1, $user2, $d)
{
$this->matchID++;
$this->nextGameDateTime($d, $filteredPlayers);
return [
'id' => $this->matchID,
'type' => random_int(1,2) == 1 ? '3' : '9',
'player1_user_id' => $user1,
'player2_user_id' => $user2,
'winner_user_id' => null,
'loser_user_id' => null,
'status' => 'Ended',
'stake' => random_int(1,4) > 1 ? 3 : random_int(4,100),
'began_at' => $d->copy(),
'ended_at' => null,
'total_time' => null,
'player1_marks' => null,
'player2_marks' => null,
'player1_points' => null,
'player2_points' => null,
'custom' => null
];
}
private function updateMatchWinner(&$match, $player1Marks, $player2Marks, $totalPlayers1, $totalPlayers2, $d)
{
$match['player1_marks'] = $player1Marks;
$match['player2_marks'] = $player2Marks;
$match['player1_points'] = $totalPlayers1;
$match['player2_points'] = $totalPlayers2;
$match['ended_at'] = $d->copy();
$match['total_time'] = $match['began_at']->diffInSeconds($match['ended_at']);
$match['winner_user_id'] = $player1Marks > $player2Marks ? $match['player1_user_id'] : ($player2Marks > $player1Marks ? $match['player2_user_id'] : null);
$match['loser_user_id'] = $player1Marks > $player2Marks ? $match['player2_user_id'] : ($player2Marks > $player1Marks ? $match['player1_user_id'] : null);
}
private $gameID = 0;
private function newGame($filteredPlayers, $match, $user1, $user2, $d)
{
$this->gameID++;
$this->nextGameDateTime($d, $filteredPlayers, $match != null);
$begin_d = $d->copy();
$pointsUser1 = 60;
$pointsUser2 = 60;
// if random == 1 it is a draw
if (random_int(1,30) > 1) {
$pointsUser1 = rand(0, 120);
$pointsUser2 = 120 - $pointsUser1;
}
$duration = random_int(200, 900);
$d->addSeconds($duration);
return [
'id' => $this->gameID,
'type' => $match ? $match['type'] : (random_int(1, 2) == 1 ? '3' : '9'),
'match_id' => $match ? $match['id'] : null,
'player1_user_id' => $user1,
'player2_user_id' => $user2,
'is_draw' => $pointsUser1 == $pointsUser2,
'winner_user_id' => $pointsUser1 > $pointsUser2 ? $user1 : ($pointsUser2 > $pointsUser1 ? $user2 : null),
'loser_user_id' => $pointsUser1 < $pointsUser2 ? $user1 : ($pointsUser2 < $pointsUser1 ? $user2 : null),
'status' => 'Ended',
'began_at' => $begin_d,
'ended_at' => $d->copy(),
'total_time' => $duration,
'player1_points' => $pointsUser1,
'player2_points' => $pointsUser2,
'custom' => null
];
}
}
@@ -0,0 +1,265 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class GamesTransactionsSeeder extends Seeder
{
private $faker = null;
private $users = null;
public function run(): void
{
$this->command->info("Create game related Transactions");
$this->faker = \Faker\Factory::create(DatabaseSeeder::$seedLanguage);
$this->users = DB::table('users')->orderBy('id', 'asc')->get();
$games = DB::table('games')->whereNull('match_id')->orderBy('began_at', 'asc')->get();
$matches = DB::table('matches')->orderBy('began_at', 'asc')->get();
$coin_purchases = [];
$coin_transactions = [];
$i = 0;
while($games->count() > 0 || $matches->count() > 0) {
$firstGame = $games->first();
$firstMatch = $matches->first();
$isGameFirst = false;
if ($firstGame && $firstMatch) {
$isGameFirst = $firstGame->began_at < $firstMatch->began_at;
} elseif ($firstGame && !$firstMatch) {
$isGameFirst = true;
} elseif (!$firstGame && $firstMatch) {
$isGameFirst = false;
}
if ($isGameFirst) {
$this->handleGame($coin_purchases, $coin_transactions, $firstGame);
$games->shift();
} else {
$this->handleMatch($coin_purchases, $coin_transactions, $firstMatch);
$matches->shift();
}
$i++;
if ($i >= DatabaseSeeder::$dbInsertBlockSize) {
$this->command->info("Block of coin purchases and transactions");
if (!empty($coin_transactions)) {
DB::table('coin_transactions')->insert($coin_transactions);
$this->command->info("Saved " . count($coin_transactions) . " coin transactions");
}
if (!empty($coin_purchases)) {
DB::table('coin_purchases')->insert($coin_purchases);
$this->command->info("Saved " . count($coin_purchases) . " coin purchases");
}
$i = 0;
$coin_purchases = [];
$coin_transactions = [];
}
}
$this->command->info("Last block of coin purchases and transactions");
if (!empty($coin_transactions)) {
DB::table('coin_transactions')->insert($coin_transactions);
$this->command->info("Saved " . count($coin_transactions) . " coin transactions");
}
if (!empty($coin_purchases)) {
DB::table('coin_purchases')->insert($coin_purchases);
$this->command->info("Saved " . count($coin_purchases) . " coin purchases");
}
$this->updateAllUsersBalance();
$this->command->info("Game related Transactions Created Successfully.");
}
private function getTimeStampFromDB($strDateFromDB, $minusOneSecond = false)
{
if ($minusOneSecond) {
return date("Y-m-d H:i:s", strtotime($strDateFromDB . " - 1 second"));
}
return date("Y-m-d H:i:s", strtotime($strDateFromDB));
}
private function getRandomPayment($user, &$type, &$ref): void
{
$type = $this->faker->randomElement(['MBWAY', 'PAYPAL', 'IBAN', 'MB', 'VISA']);
switch ($type) {
case 'MBWAY':
$ref = rand(910000000, 999999999);
break;
case 'PAYPAL':
$ref = $user->email;
break;
case 'IBAN':
$ref = 'PT' . rand(5000000000000, 9999999999999) . rand(1000000000, 9999999999);
break;
case 'MB':
$ref = rand(10000, 99999) . '-' . rand(100000000, 999999999);
break;
case 'VISA':
$ref = rand(40000000, 49999999) . rand(10000000, 99999999);
break;
}
}
private $purchaseID = null;
private function addPurchase(&$coin_purchases, &$coin_transactions, &$user, $time, $eurosAmount)
{
$this->purchaseID++;
$coins = $eurosAmount * 10;
$newCoinTransaction = $this->addCoinTransaction($coin_transactions, $user, $coins, 2, $time, null, null);
$this->getRandomPayment($user, $paymentType, $paymentRef);
$coin_purchases[] = [
'id' => $this->purchaseID,
'purchase_datetime' => $time,
'user_id' => $user->id,
'coin_transaction_id' => $newCoinTransaction['id'],
'euros' => $eurosAmount,
'payment_type' => $paymentType,
'payment_reference' => $paymentRef,
'custom' => null,
];
}
private $transactionID = 0;
private function addCoinTransaction(&$coin_transactions, &$user, $coins, $type, $time, $game_id = null, $match_id = null)
{
if ($this->transactionID == null) {
$this->transactionID = DB::table('coin_transactions')->max('id');
}
// Types of coin transactions:
// 1 - Bonus
// 2 - Coin purchase
// 3 - Game fee - requires game_id
// 4 - Match stake - requires match_id
// 5 - Game payout - requires game_id
// 6 - Match payout - requires match_id
if(($type == 3 || $type == 5) && $game_id === null) {
throw new \Exception("Game ID is required for coin transaction type $type");
}
if(($type == 4 || $type == 6) && $match_id === null) {
throw new \Exception("Match ID is required for coin transaction type $type");
}
$this->transactionID++;
$coins = abs($coins);
if (in_array($type, [3, 4])) {
$coins *= -1;
}
$newCoinTransaction = [
'id' => $this->transactionID,
'transaction_datetime' => $time,
'user_id' => $user->id,
'match_id' => $match_id, // nullable
'game_id' => $game_id, // nullable
'coin_transaction_type_id' => $type,
'coins' => $coins,
'custom' => null,
];
$coin_transactions[] = $newCoinTransaction;
$user->coins_balance += $coins;
return $newCoinTransaction;
}
private function calculateGamePayouts($game)
{
$payouts = [0, 0];
if ($game->player1_points == $game->player2_points) {
$payouts = [1, 1];
} elseif ($game->player1_points == 120) {
$payouts = [6, 0];
} elseif ($game->player2_points == 120) {
$payouts = [0, 6];
} elseif ($game->player1_points >= 91) {
$payouts = [4, 0];
} elseif ($game->player2_points >= 91) {
$payouts = [0, 4];
} elseif ($game->player1_points >= 61) {
$payouts = [3, 0];
} elseif ($game->player2_points >= 61) {
$payouts = [0, 3];
} else { // this condition should never be reached
$payouts = [0, 0];
}
return $payouts;
}
private function calculateMatchPayouts($match)
{
$payouts = [0, 0];
if ($match->winner_user_id == $match->player1_user_id) {
$payouts = [$match->stake * 2 - 1, 0];
} elseif ($match->winner_user_id == $match->player2_user_id) {
$payouts = [0, $match->stake * 2 - 1];
}
return $payouts;
}
private function handleGame(&$coin_purchases, &$coin_transactions, $game)
{
$player1 = $this->users->where('id', $game->player1_user_id)->first();
$player2 = $this->users->where('id', $game->player2_user_id)->first();
// not enough coins to play - must purchase before the game
$timeOneSecondBefore = $this->getTimeStampFromDB($game->began_at, true);
if ($player1->coins_balance < 2) {
$this->addPurchase($coin_purchases, $coin_transactions, $player1, $timeOneSecondBefore, random_int(1, 10));
}
// not enough coins to play - must purchase before the game
if ($player2->coins_balance < 2) {
$this->addPurchase($coin_purchases, $coin_transactions, $player2, $timeOneSecondBefore, random_int(1, 10));
}
$this->addCoinTransaction($coin_transactions, $player1, -2, 3, $this->getTimeStampFromDB($game->began_at, false), $game->id);
$this->addCoinTransaction($coin_transactions, $player2, -2, 3, $this->getTimeStampFromDB($game->began_at, false), $game->id);
$payouts = $this->calculateGamePayouts($game);
if ($payouts[0] > 0) {
$this->addCoinTransaction($coin_transactions, $player1, $payouts[0], 5, $this->getTimeStampFromDB($game->ended_at, false), $game->id);
}
if ($payouts[1] > 0) {
$this->addCoinTransaction($coin_transactions, $player2, $payouts[1], 5, $this->getTimeStampFromDB($game->ended_at, false), $game->id);
}
}
private function handleMatch(&$coin_purchases, &$coin_transactions, $match)
{
$player1 = $this->users->where('id', $match->player1_user_id)->first();
$player2 = $this->users->where('id', $match->player2_user_id)->first();
// not enough coins to play - must purchase before the match
$timeOneSecondBefore = $this->getTimeStampFromDB($match->began_at, true);
if ($player1->coins_balance < $match->stake) {
$requiredCoins = $match->stake - $player1->coins_balance;
$euros = ceil(($requiredCoins + 3) / 10);
$this->addPurchase($coin_purchases, $coin_transactions, $player1, $timeOneSecondBefore, $euros);
}
// not enough coins to play - must purchase before the match
if ($player2->coins_balance < $match->stake) {
$requiredCoins = $match->stake - $player2->coins_balance;
$euros = ceil(($requiredCoins + 3) / 10);
$this->addPurchase($coin_purchases, $coin_transactions, $player2, $timeOneSecondBefore, $euros);
}
$this->addCoinTransaction($coin_transactions, $player1, $match->stake * -1, 4, $this->getTimeStampFromDB($match->began_at, false), null, $match->id);
$this->addCoinTransaction($coin_transactions, $player2, $match->stake * -1, 4, $this->getTimeStampFromDB($match->began_at, false), null, $match->id);
$payouts = $this->calculateMatchPayouts($match);
if ($payouts[0] > 0) {
$this->addCoinTransaction($coin_transactions, $player1, $payouts[0], 6, $this->getTimeStampFromDB($match->ended_at, false), null, $match->id);
}
if ($payouts[1] > 0) {
$this->addCoinTransaction($coin_transactions, $player2, $payouts[1], 6, $this->getTimeStampFromDB($match->ended_at, false), null, $match->id);
}
}
private function updateAllUsersBalance()
{
$this->command->info("Update users balances...");
foreach ($this->users as $user) {
DB::table('users')->where('id', $user->id)->update(['coins_balance' => $user->coins_balance]);
}
$this->command->info("All users balances updated.");
}
}
@@ -0,0 +1,62 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use stdClass;
class InitialTransactionsSeeder extends Seeder
{
private $allPlayers;
private $sizeOfSaveBlock = 200;
private $valueOfInitialBonus = 10;
public function run(): void
{
$this->allPlayers = DB::table('users')->where('type', 'P')->get();
$this->command->info("Create initial Bonuses transactions");
$i = $this->sizeOfSaveBlock;
$dataBlock = [];
foreach ($this->allPlayers as $player) {
if ($i <= 0) {
$this->saveDataBlock($dataBlock);
$i = $this->sizeOfSaveBlock;
$dataBlock = [];
}
$dataBlock[] = $this->createBonusTransaction($player);
$i--;
}
if (!empty($dataBlock)) {
$this->saveDataBlock($dataBlock);
}
$this->updateAllPlayerBalances();
}
private function saveDataBlock($dataBlock): void
{
$size = count($dataBlock);
DB::table('coin_transactions')->insert($dataBlock);
$this->command->info("Saved $size initial bonuses transactions");
}
private function createBonusTransaction($player): array
{
return [
'transaction_datetime' => $player->created_at,
'user_id' => $player->id,
'match_id' => null,
'game_id' => null,
'coin_transaction_type_id' => 1,
'coins' => $this->valueOfInitialBonus,
'custom' => null,
];
}
private function updateAllPlayerBalances(): void
{
DB::table('users')->where('type', 'P')->update(['coins_balance' => $this->valueOfInitialBonus]);
$this->command->info("Updated all players initial Balance");
}
}
+149
View File
@@ -0,0 +1,149 @@
<?php
namespace Database\Seeders;
use Illuminate\Support\Facades\File;
trait SeederUtils
{
private static $used_emails = [];
public function randomString(int $length = 10): string
{
return substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, $length);
}
public function integerAsStringWithPadding(int $num, int $length = 10): string
{
return str_pad((string) $num, $length, '0', STR_PAD_LEFT);
}
public function randomIntegerAsStringWithPadding(int $min = 0, int $max = 100, int $length = 10): string
{
return $this->integerAsStringWithPadding($this->mt_rand($min, $max), $length);
}
public function randomDecimal(float $min, float $max, int $decimals = 2): float
{
$factor = pow(10, $decimals);
return mt_rand($min * $factor, $max * $factor) / $factor;
}
public function getFileNameFromString($str, $extension)
{
return str_replace(' ', '_', strtolower($this->stripAccents($str))) . ".$extension";
}
public function stripAccents($stripAccents)
{
$from = 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ';
$to = 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY';
$keys = array();
$values = array();
preg_match_all('/./u', $from, $keys);
preg_match_all('/./u', $to, $values);
$mapping = array_combine($keys[0], $values[0]);
return strtr($stripAccents, $mapping);
}
public function strtr_utf8($str, $from, $to)
{
$keys = array();
$values = array();
preg_match_all('/./u', $from, $keys);
preg_match_all('/./u', $to, $values);
$mapping = array_combine($keys[0], $values[0]);
return strtr($str, $mapping);
}
public function randomName($faker, &$gender, &$fullname, &$email, $allowRepeated = false)
{
$gender = $gender ?? $faker->randomElement(['male', 'female']);
$firstname = $faker->firstName($gender);
$lastname = $faker->lastName();
$secondname = mt_rand(1, 3) == 2 ? "" : " " . $faker->firstName($gender);
$number_middlenames = $faker->randomElement([0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3]);
$middlenames = "";
for ($i = 0; $i < $number_middlenames; $i++) {
$middlenames .= " " . $faker->lastName();
}
$fullname = $firstname . $secondname . $middlenames . " " . $lastname;
$email = strtolower($this->stripAccents($firstname) . "." . $this->stripAccents($lastname) . "@mail.pt");
if (!$allowRepeated) {
$i = 2;
while (in_array($email, self::$used_emails)) {
$email = strtolower($this->stripAccents($firstname) . "." . $this->stripAccents($lastname) . "." . $i ."@mail.pt");
$i++;
if ($i > 10) {
$this->command->error("Repeated email - not possible to create a unique email for $fullname!");
exit(1);
}
}
}
self::$used_emails[] = $email;
$gender = $gender == 'male' ? 'M' : 'F';
}
public function ramdomPaymentMethod($email, &$paymentType, &$paymentReference)
{
$paymentType = $this->faker->randomElement(['Visa', 'PayPal', 'MB WAY']);
$paymentReference = match ($paymentType) {
'Visa' => mt_rand(4, 6) .
$this->faker->randomNumber($nbDigits = 8, $strict = true) .
$this->faker->randomNumber($nbDigits = 7, $strict = true),
'PayPal' => $email,
'MB WAY' => '9' . $this->faker->randomNumber($nbDigits = 8, $strict = true)
};
}
public function cleanStorageFolder($folder, $public = true)
{
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
if (File::exists($storagePath)) {
File::deleteDirectory($storagePath);
}
if (!File::exists(storage_path("app"))) {
File::makeDirectory(storage_path("app"));
}
if ($public) {
if (!File::exists(storage_path("app/public"))) {
File::makeDirectory(storage_path("app/public"));
}
} else {
if (!File::exists(storage_path("app/private"))) {
File::makeDirectory(storage_path("app/private"));
}
}
File::makeDirectory($storagePath);
}
public function copyFileToStorage($originalFolder, $originalFileName, $folder, $id = null, $public = true)
{
$originalFullName = database_path("seeders/$originalFolder") . '/' . $originalFileName;
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
$prefix = $id ? $this->integerAsStringWithPadding($id, 5) . '_' : '';
$ext = pathinfo($originalFullName, PATHINFO_EXTENSION);
$newFileName = $prefix . $this->randomString(10) . '.' . $ext;
if (!File::exists($storagePath)) {
File::makeDirectory($storagePath);
}
if (File::exists($originalFullName)) {
File::copy($originalFullName, "$storagePath/$newFileName");
return $newFileName;
}
return null;
}
public function directCopyFileToStorage($originalFolder, $originalFileName, $folder, $public = true)
{
$originalFullName = database_path("seeders/$originalFolder") . '/' . $originalFileName;
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
if (!File::exists($storagePath)) {
File::makeDirectory($storagePath);
}
File::copy($originalFullName, "$storagePath/$originalFileName");
return $originalFileName;
}
}
@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class TransactionTypesSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$this->command->line("Creating Coin Transaction Types.");
// Add default coin_transaction_types
DB::table('coin_transaction_types')->insert([
['id' => 1, 'name' => 'Bonus', 'type' => 'C'], // id = 1
['id' => 2, 'name' => 'Coin purchase', 'type' => 'C'], // id = 2
['id' => 3, 'name' => 'Game fee', 'type' => 'D'], // id = 3
['id' => 4, 'name' => 'Match stake', 'type' => 'D'], // id = 4
['id' => 5, 'name' => 'Game payout', 'type' => 'C'], // id = 5
['id' => 6, 'name' => 'Match payout', 'type' => 'C'], // id = 6
]);
$this->command->line("Coin Transaction Types Created Successfully.");
}
}
+173
View File
@@ -0,0 +1,173 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Faker\Factory;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use stdClass;
class UsersSeeder extends Seeder
{
use SeederUtils;
private $faker = null;
private $files_M = [];
private $files_F = [];
public static $hashPasword = "";
public static $dbUsers = null;
public static $fixedUsers = [
['type' => 'A', 'name' => 'First Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'A', 'name' => 'Second Administrator', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'A', 'name' => 'Third Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'A', 'name' => 'Forth Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
['type' => 'P', 'name' => 'Player A', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'P', 'name' => 'Player B', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'P', 'name' => 'Player C', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'P', 'name' => 'Player D', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
['type' => 'P', 'name' => 'Player E', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'P', 'name' => 'Player F', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
];
public static $userTypes = [
'A' => 10,
'P' => 500];
public function run(): void
{
$this->command->line("Creating Users.");
self::$hashPasword = bcrypt('123');
//$this->faker = Factory::create('pt_PT');
$this->faker = Factory::create(DatabaseSeeder::$seedLanguage);
$this->cleanStorageFolder('photos_avatars');
$this->addUsersToDatabase();
$this->addPhotoFiles();
DB::table('users')->where('type', 'A')->update(['nickname' => null]);
self::$dbUsers = DB::table('users')->orderBy('id')->get();
$this->command->line("Users Created Successfully.");
}
private function addUsersToDatabase()
{
$this->command->line("Adding users to the database");
$usersAdded = Self::$fixedUsers;
foreach (self::$userTypes as $userType => $totalUsers) {
for ($i = 0; $i < $totalUsers; $i++) {
$gender = null;
$name = null;
$email = null;
$this->randomName($this->faker, $gender, $name, $email, false);
$usersAdded[] = [
'type' => $userType,
'name' => $name,
'email' => $email,
'gender' => $gender,
'softdelete' => random_int(1, 20) == 1,
];
}
}
$createdDate = DatabaseSeeder::$startDate->copy()->addMinutes(mt_rand(20000, 100000));
foreach ($usersAdded as $key => $user) {
$usersAdded[$key]['password'] = self::$hashPasword;
$createdDate = $createdDate->copy()->addMinutes(mt_rand(10, 60));
$usersAdded[$key]['created_at'] = $createdDate;
$usersAdded[$key]['email_verified_at'] = $createdDate->copy()->addMinutes(mt_rand(1, 9));
if (random_int(1, 7) > 1) {
$usersAdded[$key]['updated_at'] = $createdDate->copy()->addMinutes(mt_rand(10, 10000));
} else {
$usersAdded[$key]['updated_at'] = $createdDate;
}
$usersAdded[$key]['nickname'] = ($user['gender'] == 'M' ? 'Mickey' : 'Minnie') . ($key + 1) ;
$usersAdded[$key]['blocked'] = false;
$usersAdded[$key]['photo_avatar_filename'] = null;
$usersAdded[$key]['coins_balance'] = 0;
$usersAdded[$key]['deleted_at'] = null;
if ($usersAdded[$key]['softdelete']) {
$usersAdded[$key]['deleted_at'] = $createdDate->copy()->addMinutes(mt_rand(10001, 100000));
}
}
$arrayToStore = [];
foreach ($usersAdded as $user) {
unset($user['gender']);
unset($user['softdelete']);
$arrayToStore[] = $user;
if (count($arrayToStore) >= DatabaseSeeder::$dbInsertBlockSize) {
DB::table('users')->insert($arrayToStore);
$this->command->line("Created " . count($arrayToStore) . " users");
$arrayToStore = [];
}
}
if (count($arrayToStore) >= 1) {
DB::table('users')->insert($arrayToStore);
$this->command->line("Created " . count($arrayToStore) . " users");
}
$this->command->line("Total users created: " . DB::table('users')->count());
self::$dbUsers = DB::table('users')->get();
print_r(self::$dbUsers);
}
private function addPhotoFiles()
{
$this->command->line("Copying users' photos");
$this->fillPhotoFilesNames();
$total = count($this->files_M) + count($this->files_F);
$sortedUsers = self::$dbUsers->sortBy(function (stdClass $user) {
if ($user->id <= 10 ) {
return $user->id;
}
return match($user->type) {
'A' => 20 + $user->id,
'P' => 1000 + $user->id,
default => ($user->id < 50) ? 2000 + $user->id : 3000 + mt_rand(0, 100000),
};
});
$i = 0;
foreach($sortedUsers as $user) {
$originalFilename = str_starts_with($user->nickname, 'Mickey') ? array_shift($this->files_M) : array_shift($this->files_F);
if (!$originalFilename) {
if ((count($this->files_M) == 0) && (count($this->files_F) == 0))
break;
}
if ($originalFilename) {
$originalFilename = basename($originalFilename);
$newFileName = $this->copyFileToStorage('photos', $originalFilename, 'photos_avatars', $user->id);
$user->photo_avatar_filename = $newFileName;
DB::table('users')->where('id', $user->id)->update(['photo_avatar_filename' => $user->photo_avatar_filename]);
$i++;
if ($i % 10 == 0) {
$this->command->line("User photo $i/$total copied");
}
}
}
$this->command->line("Total of $total user's photos were copied!");
$this->directCopyFileToStorage('photos', 'anonymous.png', 'photos_avatars');
$this->command->line("Image for user with no associated photo was copied!");
}
private function fillPhotoFilesNames()
{
$allFiles = collect(File::files(database_path('seeders/photos')));
foreach ($allFiles as $f) {
if (strpos($f->getPathname(), 'm_')) {
$this->files_M[] = $f->getPathname();
} else if (strpos($f->getPathname(), 'w_')) {
$this->files_F[] = $f->getPathname();
}
}
shuffle($this->files_M);
shuffle($this->files_F);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 KiB

Some files were not shown because too many files have changed in this diff Show More