Skip to content

Commit c20dcfd

Browse files
committed
Starting game areas. Changed any public model to use uniqueId as the primary. Corrected all xref keys to match.
1 parent a58bd42 commit c20dcfd

36 files changed

+675
-82
lines changed

app/controllers/Admin/CrudController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public function getUsers()
3737
$settings->title = 'Users';
3838
$settings->sort = 'username';
3939
$settings->deleteLink = '/admin/crud/userDelete/';
40-
$settings->deleteProperty = 'id';
40+
$settings->deleteProperty = 'uniqueId';
4141
$settings->buttons = array
4242
(
43-
'resetPassword' => HTML::link('/admin/crud/resetPassword/--id--', 'Reset Password', array('class' => 'confirm-continue btn btn-mini btn-primary'))
43+
'resetPassword' => HTML::link('/admin/crud/resetPassword/--uniqueId--', 'Reset Password', array('class' => 'confirm-continue btn btn-mini btn-primary'))
4444
);
4545
$settings->displayFields = array
4646
(
47-
'username' => array('link' => '/profile/user/', 'linkProperty' => 'id'),
47+
'username' => array('link' => '/profile/user/', 'linkProperty' => 'uniqueId'),
4848
'fullname' => array(),
4949
'email' => array('link' => 'mailto'),
5050
);

app/controllers/DefaultController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getMenu()
3232
$rooms = array();
3333
if (count($chatRooms) > 0) {
3434
foreach ($chatRooms as $chatRoom) {
35-
$rooms[$chatRoom->name] = 'chat/room/'. $chatRoom->id;
35+
$rooms[$chatRoom->name] = 'chat/room/'. $chatRoom->uniqueId;
3636
}
3737
}
3838
$this->addMenu(

app/controllers/GameController.php

+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?php
2+
3+
class GameController extends BaseController {
4+
5+
public function subLinks($gameSlug)
6+
{
7+
$this->addSubMenu('Manage Game','game/manage/'. $gameSlug);
8+
$this->addSubMenu('Manage Details', 'game/manageDetails/'. $gameSlug);
9+
}
10+
11+
public function getIndex($gameId = null, $property = null, $value = null)
12+
{
13+
// If passed values, handle them first
14+
if ($gameId != null) {
15+
$game = Game::where('uniqueId', $gameId)->first();
16+
$game->{$property} = $value;
17+
$game->save();
18+
$this->redirect('games', null);
19+
}
20+
21+
// Set the template details
22+
$games = Game::with(array('storytellers', 'storytellers.user', 'forum'))->orderByNameAsc()->get();
23+
$this->setViewData('games', $games);
24+
}
25+
26+
public function action_manageDetails($gameSlug)
27+
{
28+
// Add links
29+
$this->subLinks($gameSlug);
30+
31+
$game = Game::where('slug', '=', $gameSlug)->first();
32+
33+
$this->setTemplate(array('gameId' => $game->id));
34+
}
35+
36+
public function action_manage($gameSlug = null)
37+
{
38+
// Add links
39+
$this->subLinks($gameSlug);
40+
41+
// Set the template details
42+
if ($gameSlug != null) {
43+
$game = Game::with(array('storytellers', 'storytellers.user', 'characters', 'notes'))->where('slug', '=', $gameSlug)->first();
44+
$forum = new Forum;
45+
if ($game->forum != null) {
46+
$recentPosts = $forum->recentCategoryPosts($game->forum->id);
47+
} else {
48+
$recentPosts = array();
49+
}
50+
$this->setTemplate(array('game' => $game, 'recentPosts' => $recentPosts));
51+
} else {
52+
$this->setTemplate();
53+
}
54+
55+
// Handle form input
56+
$input = Input::all();
57+
58+
if ($input != null) {
59+
$character = Character::find($input['character_id']);
60+
if (isset($input['exp'])) {
61+
$character->addExperience($input['exp'], $this->activeUser->id, $input['reason']);
62+
}
63+
return Redirect::to(URI::current())->with('message', $character->name .' has been granted '. $input['exp'] .' experience points.');
64+
}
65+
}
66+
67+
public function action_update($resourceId, $property, $value, $type = 'character')
68+
{
69+
switch ($type) {
70+
case 'character':
71+
$resource = Character::find($resourceId);
72+
break;
73+
case 'post':
74+
$resource = Forum\Post::find($resourceId);
75+
break;
76+
case 'reply':
77+
$resource = Forum\Reply::find($resourceId);
78+
break;
79+
case 'tree':
80+
$resource = Game\Template\Magic\Tree::find($resourceId);
81+
break;
82+
case 'spell':
83+
$resource = Game\Template\Spell::find($resourceId);
84+
break;
85+
case 'characterSpell':
86+
$resource = Character\Spell::find($resourceId);
87+
break;
88+
}
89+
$resource->{$property} = $value;
90+
$resource->save();
91+
return Redirect::back()->with('message', $resource->name .' successfully updated.');
92+
}
93+
94+
public function action_denySpell($spellId)
95+
{
96+
$spell = Game\Template\Spell::find($spellId);
97+
$spell->delete();
98+
return Redirect::back()->with('message', 'Spell has been denied.');
99+
}
100+
101+
public function action_denyCharacterSpell($spellId)
102+
{
103+
$spell = Character\Spell::find($spellId);
104+
$spell->delete();
105+
return Redirect::back()->with('message', 'Spell has been denied.');
106+
}
107+
108+
public function getAdd()
109+
{
110+
// Set the template details
111+
$types = $this->arrayToSelect(Game_Type::orderByNameAsc()->get(), 'id', 'name', 'Select a game type');
112+
$this->setViewData('types', $types);
113+
}
114+
115+
public function postAdd()
116+
{
117+
// Handle any form inputs
118+
$input = Input::all();
119+
if ($input != null) {
120+
$game = new Game;
121+
$game->game_type_id = $input['game_type_id'];
122+
$game->name = $input['name'];
123+
$game->keyName = Str::slug($input['name']);
124+
$game->description = $input['description'];
125+
$game->activeFlag = (isset($input['activeFlag']) ? 1 : 0);
126+
127+
$game->save();
128+
129+
$this->checkErrorsRedirect($game);
130+
131+
$storyTeller = new Game_StoryTeller(array('game_id' => $game->id, 'user_id' => $this->activeUser->id));
132+
133+
$game->storytellers()->save($storyTeller);
134+
135+
return Redirect::to('game')->with('message', $game->name.' has been created.');
136+
}
137+
}
138+
139+
public function action_edit($gameId)
140+
{
141+
// Set the template details
142+
$game = Game::find($gameId);
143+
$templates = $this->arrayToSelect(Game\Template::order_by('name', 'asc')->get(), 'id', 'name', 'Select a template');
144+
$this->setTemplate(array('game' => $game, 'templates' => $templates));
145+
146+
// Handle any form inputs
147+
$input = Input::all();
148+
if ($input != null) {
149+
$game->game_template_id = $input['game_template_id'];
150+
$game->name = $input['name'];
151+
$game->description = $input['description'];
152+
$game->activeFlag = (isset($input['activeFlag']) ? 1 : 0);
153+
$game->hitPointsName = $input['hitPointsName'];
154+
$game->magicPointsName = $input['magicPointsName'];
155+
156+
$game->save();
157+
158+
if (count($game->errors->all()) > 0){
159+
return Redirect::to(URI::current())->with_errors($game->errors->all());
160+
} else {
161+
return Redirect::to('game')->with('message', $game->name.' has been edited.');
162+
}
163+
}
164+
}
165+
166+
public function action_delete($gameId)
167+
{
168+
$game = Game::find($gameId);
169+
$game->delete();
170+
$storyTellers = Game\StoryTeller::where('game_id', '=', $game->id)->get();
171+
if (count($storyTellers) > 0) {
172+
foreach ($storyTellers as $storyTeller) {
173+
$storyTeller->delete();
174+
}
175+
}
176+
$notes = Game\Note::where('game_id', '=', $game->id)->get();
177+
if (count($notes) > 0) {
178+
foreach ($notes as $note) {
179+
$note->delete();
180+
}
181+
}
182+
return Redirect::to('game')->with('message', $game->name.' has been deleted.');
183+
}
184+
185+
public function action_denyTree($treeId)
186+
{
187+
$tree = Game\Template\Magic\Tree::find($treeId);
188+
$tree->delete();
189+
return Redirect::back()->with('message', $tree->name .' has been denied.');
190+
}
191+
192+
public function action_memberlist($gameId)
193+
{
194+
// Get the characters
195+
$game = Game::find($gameId);
196+
$characters = Character::where('game_id', '=', $gameId)->where('activeFlag', '=', 1)->where('npcFlag', '=', 0)->order_by('name', 'ASC')->get();
197+
$this->setTemplate(array('game' => $game, 'characters' => $characters));
198+
}
199+
}

app/database/migrations/2013_05_14_174140_create_forum_moderation_table.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public function up()
1414
{
1515
Schema::create('forum_moderation', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->string('resource_name')->index();
18-
$table->integer('resource_id')->index();
19-
$table->integer('user_id')->index();
17+
$table->string('resourceType')->index();
18+
$table->string('resourceId', 11)->index();
19+
$table->string('user_id', 10)->index();
2020
$table->text('reason');
2121
$table->timestamps();
2222
});

app/database/migrations/2013_05_14_174244_create_forum_post_status_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('forum_post_status', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('forum_post_id')->index();
17+
$table->string('forum_post_id', 10)->index();
1818
$table->integer('forum_support_status_id')->index();
1919
$table->timestamps();
2020
});

app/database/migrations/2013_05_14_202942_create_forum_categories_table.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class CreateForumCategoriesTable extends Migration {
1313
public function up()
1414
{
1515
Schema::create('forum_categories', function(Blueprint $table) {
16-
$table->increments('id');
17-
$table->string('uniqueId')->index();
16+
$table->string('uniqueId', 10);
17+
$table->primary('uniqueId');
1818
$table->integer('forum_category_type_id')->index();
1919
$table->string('name');
2020
$table->string('keyName')->index();
2121
$table->text('description');
2222
$table->integer('position')->nullable()->index();
23-
$table->integer('game_id')->nullable()->index();
23+
$table->string('game_id', 10)->nullable()->index();
2424
$table->timestamps();
2525
});
2626
}

app/database/migrations/2013_05_14_202959_create_forum_boards_table.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class CreateForumBoardsTable extends Migration {
1313
public function up()
1414
{
1515
Schema::create('forum_boards', function(Blueprint $table) {
16-
$table->increments('id');
17-
$table->string('uniqueId')->index();
18-
$table->integer('forum_category_id')->index();
16+
$table->string('uniqueId', 10);
17+
$table->primary('uniqueId');
18+
$table->string('forum_category_id', 10)->index();
1919
$table->integer('forum_board_type_id')->index();
2020
$table->string('name');
2121
$table->string('keyName')->index();
2222
$table->text('description');
2323
$table->integer('position')->nullable()->index();
24-
$table->integer('parent_id')->nullable()->index();
24+
$table->string('parent_id', 10)->nullable()->index();
2525
$table->timestamps();
2626
});
2727
}

app/database/migrations/2013_05_14_203017_create_forum_posts_table.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class CreateForumPostsTable extends Migration {
1313
public function up()
1414
{
1515
Schema::create('forum_posts', function(Blueprint $table) {
16-
$table->increments('id');
17-
$table->string('uniqueId')->index();
18-
$table->integer('forum_board_id')->index();
16+
$table->string('uniqueId', 10);
17+
$table->primary('uniqueId');
18+
$table->string('forum_board_id', 10)->index();
1919
$table->integer('forum_post_type_id')->index();
20-
$table->integer('user_id')->index();
21-
$table->integer('character_id')->index()->nullable();
20+
$table->string('user_id', 10)->index();
21+
$table->string('character_id', 10)->index()->nullable();
2222
$table->string('name');
2323
$table->string('keyName')->index();
2424
$table->text('content');

app/database/migrations/2013_05_14_203040_create_forum_post_user_views_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function up()
1414
{
1515
Schema::create('forum_user_view_posts', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('user_id')->index();
18-
$table->integer('forum_post_id')->index();
17+
$table->string('user_id', 10)->index();
18+
$table->string('forum_post_id', 10)->index();
1919
$table->timestamps();
2020
});
2121
}

app/database/migrations/2013_05_14_203101_create_forum_replies_table.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class CreateForumRepliesTable extends Migration {
1313
public function up()
1414
{
1515
Schema::create('forum_replies', function(Blueprint $table) {
16-
$table->increments('id');
17-
$table->string('uniqueId')->index();
18-
$table->integer('forum_post_id')->index();
16+
$table->string('uniqueId', 10);
17+
$table->primary('uniqueId');
18+
$table->string('forum_post_id', 10)->index();
1919
$table->integer('forum_reply_type_id')->index();
20-
$table->integer('user_id')->index();
21-
$table->integer('character_id')->index()->nullable();
20+
$table->string('user_id', 10)->index();
21+
$table->string('character_id', 10)->index()->nullable();
2222
$table->string('name');
2323
$table->string('keyName');
2424
$table->text('content');
25-
$table->integer('quote_id')->index()->nullable();
25+
$table->string('quote_id', 10)->index()->nullable();
2626
$table->string('quote_type')->nullable();
2727
$table->boolean('moderatorLockedFlag')->default(0);
2828
$table->boolean('approvedFlag')->index();

app/database/migrations/2013_05_14_205130_create_forum_post_edits_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function up()
1414
{
1515
Schema::create('forum_post_edits', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('forum_post_id')->index();
18-
$table->integer('user_id')->index();
17+
$table->string('forum_post_id', 10)->index();
18+
$table->string('user_id', 10)->index();
1919
$table->text('reason')->nullable();
2020
$table->timestamps();
2121
});

app/database/migrations/2013_05_14_205218_create_forum_reply_edits_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function up()
1414
{
1515
Schema::create('forum_reply_edits', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('forum_reply_id')->index();
18-
$table->integer('user_id')->index();
17+
$table->string('forum_reply_id', 10)->index();
18+
$table->string('user_id', 10)->index();
1919
$table->text('reason')->nullable();
2020
$table->timestamps();
2121
});

app/database/migrations/2013_05_14_205236_create_forum_reply_rolls_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('forum_reply_rolls', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('forum_reply_id')->index();
17+
$table->string('forum_reply_id', 10)->index();
1818
$table->integer('die');
1919
$table->integer('roll');
2020
$table->timestamps();

app/database/migrations/2013_06_21_143610_create_users_tables.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class CreateUsersTables extends Migration {
1313
public function up()
1414
{
1515
Schema::create('users', function(Blueprint $table) {
16-
$table->increments('id');
17-
$table->string('uniqueId')->index();
16+
$table->string('uniqueId', 10);
17+
$table->primary('uniqueId');
1818
$table->string('username')->unique();
1919
$table->string('password');
2020
$table->string('firstName')->index();

app/database/migrations/2013_06_21_204306_create_role_users_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function up()
1515
Schema::create('role_users', function(Blueprint $table) {
1616
$table->increments('id');
1717
$table->integer('role_id')->index();
18-
$table->integer('user_id')->index();
18+
$table->string('user_id', 10)->index();
1919
$table->timestamps();
2020
});
2121
}

0 commit comments

Comments
 (0)