@@ -5,9 +5,9 @@ class BaseController extends DefaultController {
55
66 protected $ subMenu = array ();
77
8- protected $ menu = array ();
8+ protected $ menu = array ();
99
10- protected $ data = array ();
10+ protected $ data = array ();
1111
1212 protected $ pageTitle ;
1313
@@ -21,6 +21,10 @@ class BaseController extends DefaultController {
2121
2222 protected $ skipView = false ;
2323
24+ protected $ postResponse ;
25+
26+ protected $ ajaxResponse ;
27+
2428 /**
2529 * Layouts array
2630 *
@@ -46,6 +50,10 @@ public function __construct()
4650 $ this ->activeUser ->updateLastActive ();
4751 }
4852
53+ // Set up the response classes
54+ $ this ->postResponse = new Utility_Response_Post (Request::path ());
55+ $ this ->ajaxResponse = new Utility_Response_Ajax ();
56+
4957 // Load the menu bar
5058 $ this ->getMenu ();
5159
@@ -94,7 +102,7 @@ protected function processResponse($router, $method, $response)
94102 public function setupLayout ()
95103 {
96104 if ($ this ->route == null ) {
97- $ route = Route::getContainer ()->router ->currentRouteAction ();
105+ $ route = Route::getContainer ()->router ->currentRouteAction ();
98106 $ this ->route = $ this ->cleanRoute ($ route );
99107 }
100108
@@ -128,7 +136,7 @@ protected function cleanRoute($route, $returnArray = false)
128136 $ route = strtolower (str_replace ('Controller ' , '' , implode ('. ' , $ routeParts )));
129137
130138 if ($ returnArray ) {
131- $ routeParts = explode ('. ' , $ route );
139+ $ routeParts = explode ('. ' , $ route );
132140 }
133141
134142 return $ route ;
@@ -189,24 +197,35 @@ public function hasPermission($permissions)
189197 return false ;
190198 }
191199
192- public static function errorRedirect ()
200+ public function errorRedirect ()
193201 {
194- return Redirect::back ()->with ('errors ' , array ('You lack the permission(s) required to view this area ' ))->send ();
202+ $ this ->postResponse ->addError ('permission ' , 'You lack the permission(s) required to view this area ' );
203+ return $ this ->postResponse ->redirect ('back ' );
195204 }
196205
197- public static function redirect ($ location , $ message = null , $ back = null )
206+ public function redirect ($ location , $ message = null )
198207 {
199- if ($ message == null ) {
200- if ($ back != null ) {
201- return Redirect::back ()->send ();
202- }
203- return Redirect::to ($ location )->send ();
204- } else {
205- if ($ back != null ) {
206- return Redirect::back ()->with ('message ' , $ message )->send ();
207- }
208- return Redirect::to ($ location )->with ('message ' , $ message )->send ();
209- }
208+ return $ this ->postResponse ->redirect ($ location , $ message );
209+ }
210+
211+ public function save ($ model )
212+ {
213+ $ this ->postResponse ->save ($ model );
214+ }
215+
216+ public function errorCount ()
217+ {
218+ $ this ->postResponse ->errorCount ();
219+ }
220+
221+ public function setSuccessPath ($ path )
222+ {
223+ $ this ->postResponse ->setSuccessPath ($ path );
224+ }
225+
226+ public function setSuccessMessage ($ message )
227+ {
228+ $ this ->postResponse ->setSuccessMessage ($ message );
210229 }
211230
212231 public static function arrayToSelect ($ array , $ key = 'id ' , $ value = 'name ' , $ first = 'Select One ' )
@@ -221,20 +240,25 @@ public static function arrayToSelect($array, $key = 'id', $value = 'name', $firs
221240 return $ results ;
222241 }
223242
224- public function checkErrorsRedirect ($ model )
225- {
226- if ($ model == true && count ($ model ->getErrors ()->all ()) > 0 ) {
227- return Redirect::to (Request::path ())->with ('errors ' , $ model ->getErrors ()->all ());
228- }
229- }
243+ // public function checkErrorsRedirect($model)
244+ // {
245+ // if ($model == true && count($model->getErrors()->all()) > 0) {
246+ // return Redirect::to(Request::path())->with('errors', $model->getErrors()->all())->withInput()->send( );
247+ // }
248+ // }
230249
231- public function checkErrors ($ model )
232- {
233- if ($ model == true && count ($ model ->getErrors ()->all ()) > 0 ) {
234- return true ;
235- }
250+ // public function checkErrors($model)
251+ // {
252+ // if ($model == true && count($model->getErrors()->all()) > 0) {
253+ // return true;
254+ // }
236255
237- return false ;
256+ // return false;
257+ // }
258+
259+ public function skipView ()
260+ {
261+ $ this ->skipView = true ;
238262 }
239263
240264 public function addSubMenu ($ text , $ link , $ subLinks = array ())
@@ -270,4 +294,86 @@ public function emptyBoth()
270294 $ this ->menu = array ();
271295 $ this ->subMenu = array ();
272296 }
297+
298+ public function rollGm ()
299+ {
300+ if (!$ this ->game ->isStoryteller ($ this ->activeUser ->id )) {
301+ return $ this ->roll () .'Gm ' ;
302+ }
303+
304+ $ roll = rand (1 ,100 );
305+ $ overallRoll = $ roll ;
306+ $ class = 'text-success ' ;
307+
308+ while ($ roll <= 80 ) {
309+ $ roll = rand (1 ,100 );
310+ $ overallRoll = $ overallRoll + $ roll ;
311+ $ class = 'text-warning ' ;
312+ }
313+
314+ if ($ overallRoll == 9999 ) {
315+ $ overallRoll = 10000 ;
316+ }
317+
318+ if ($ this ->type == 'forum ' ) {
319+ return '[dice][spanClass= ' . $ class .'] ' . $ overallRoll .'[/spanClass] ' ;
320+ } elseif ($ this ->type == 'chat ' ) {
321+ return HTML ::image ('img/dice_white.png ' , null , array ('style ' => 'width: 14px; ' )) .'<span class=" ' . $ class .'"> ' . $ overallRoll .'</span> ' ;
322+ }
323+ }
324+
325+ public function roll ()
326+ {
327+ $ roll = rand (1 ,100 );
328+ $ overallRoll = $ roll ;
329+
330+ while ($ roll >= 90 ) {
331+ $ roll = rand (1 ,100 );
332+ $ overallRoll = $ overallRoll + $ roll ;
333+ }
334+
335+ if ($ overallRoll == 9999 ) {
336+ $ overallRoll = 10000 ;
337+ }
338+
339+ if ($ this ->type == 'forum ' ) {
340+ return $ overallRoll ;
341+ } elseif ($ this ->type == 'chat ' ) {
342+ return HTML ::image ('img/dice_white.png ' , null , array ('style ' => 'width: 14px; ' )) .'<span class=" ' . $ class .'"> ' . $ overallRoll .'</span> ' ;
343+ }
344+ }
345+
346+ public function roll1 ()
347+ {
348+ $ roll = rand (1 ,100 );
349+ $ overallRoll = $ roll ;
350+ $ class = 'text-success ' ;
351+
352+ while ($ roll >= 90 ) {
353+ $ roll = rand (1 ,100 );
354+ $ overallRoll = $ overallRoll + $ roll ;
355+ $ class = 'text-warning ' ;
356+ }
357+
358+ if ($ overallRoll == 9999 ) {
359+ $ overallRoll = 10000 ;
360+ }
361+
362+ if ($ this ->type == 'forum ' ) {
363+ return '[dice][spanClass= ' . $ class .'] ' . $ overallRoll .'[/spanClass] ' ;
364+ }
365+ }
366+
367+ public function roll2 ()
368+ {
369+ $ roll = rand (91 ,150 );
370+ $ overallRoll = $ roll ;
371+ $ class = 'text-warning ' ;
372+
373+ if ($ this ->type == 'forum ' ) {
374+ return '[dice][spanClass= ' . $ class .'] ' . $ overallRoll .'[/spanClass] ' ;
375+ } elseif ($ this ->type == 'chat ' ) {
376+ return HTML ::image ('img/dice_white.png ' , null , array ('style ' => 'width: 14px; ' )) .'<span class=" ' . $ class .'"> ' . $ overallRoll .'</span> ' ;
377+ }
378+ }
273379}
0 commit comments