File tree 3 files changed +11
-4
lines changed
jsbattle-engine/src/engine
jsbattle-webpage/src/components
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,8 @@ List of all settings of JsBattle:
84
84
// define each provider as separate object
85
85
{
86
86
// name of provider. Supported values are: github, facebook, google
87
- // authStrategies[' github' ] = require("passport-github2");
88
- " name" : ' github' ,
87
+ // authStrategies[" github" ] = require("passport-github2");
88
+ " name" : " github" ,
89
89
90
90
// client ID generated by OAuth provider
91
91
" clientID" : " XXXXXXXXXXXXXXXXXXXX" ,
Original file line number Diff line number Diff line change @@ -145,7 +145,9 @@ class AiDefinition {
145
145
*/
146
146
fromCode ( tankName , code , initData ) {
147
147
if ( ! tankName ) throw "tankName is required" ;
148
- if ( code === undefined ) throw "Code is required" ;
148
+ if ( ! code ) throw "Code is required" ;
149
+ if ( typeof ( tankName ) != 'string' ) throw "tankName must be a string" ;
150
+ if ( typeof ( code ) != 'string' ) throw "code must be a string" ;
149
151
code = code . replace ( / i m p o r t S c r i p t s \w * \( [ ^ \) ] * \) / g, '' ) ;
150
152
this . _name = tankName ;
151
153
this . _code = code ;
Original file line number Diff line number Diff line change @@ -65,7 +65,12 @@ class LiveCode extends React.Component {
65
65
let aiList = [ ] ;
66
66
for ( let i = 0 ; i < count ; i ++ ) {
67
67
let ai = JsBattle . createAiDefinition ( ) ;
68
- ai . fromCode ( this . props . name , code ) ;
68
+ try {
69
+ ai . fromCode ( this . props . name , code ) ;
70
+ } catch ( err ) {
71
+ console . error ( 'Unable to create AI "' + this . props . name + '" from code' , code ) ;
72
+ console . error ( err ) ;
73
+ }
69
74
aiList . push ( ai ) ;
70
75
}
71
76
return template . concat ( aiList ) ;
You can’t perform that action at this time.
0 commit comments