| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package tsukuba_bunko.peko.scenario; |
| 20 |
|
|
| 21 |
|
import java.io.Serializable; |
| 22 |
|
|
| 23 |
|
import java.util.Iterator; |
| 24 |
|
import java.util.List; |
| 25 |
|
import java.util.Map; |
| 26 |
|
|
| 27 |
|
import tsukuba_bunko.peko.Logger; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
public class NextSceneMapping implements Serializable { |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
private static final long serialVersionUID = -3896489854104011813L; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
0 |
private List _conditionList = new java.util.ArrayList(); |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
0 |
private Map _nextScenes = new java.util.HashMap(); |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
public NextSceneMapping() |
| 56 |
0 |
{ |
| 57 |
0 |
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
public void addNextSceneMapping( String condition, String nextScene ) |
| 61 |
|
{ |
| 62 |
0 |
if( _conditionList.contains(condition) ) { |
| 63 |
0 |
Logger.warn( MessageIDs.SCN0010W, new Object[]{condition, _nextScenes.get(condition), nextScene} ); |
| 64 |
0 |
} |
| 65 |
|
else { |
| 66 |
0 |
_conditionList.add( condition ); |
| 67 |
0 |
_nextScenes.put( condition, nextScene ); |
| 68 |
|
} |
| 69 |
0 |
} |
| 70 |
|
|
| 71 |
|
public void setDefaultSceneMapping( String nextScene ) |
| 72 |
|
{ |
| 73 |
0 |
setDefaultSceneMapping( nextScene, true ); |
| 74 |
0 |
} |
| 75 |
|
|
| 76 |
|
public void setDefaultSceneMapping( String nextScene, boolean warn ) |
| 77 |
|
{ |
| 78 |
0 |
if( _nextScenes.containsKey(null) && warn ) { |
| 79 |
0 |
Logger.warn( MessageIDs.SCN0010W, new Object[]{"_default_", _nextScenes.get(null), nextScene} ); |
| 80 |
0 |
} |
| 81 |
|
else { |
| 82 |
0 |
_nextScenes.put( null, nextScene ); |
| 83 |
|
} |
| 84 |
0 |
} |
| 85 |
|
|
| 86 |
|
public String getNextScene( SceneContext context ) |
| 87 |
|
{ |
| 88 |
0 |
Iterator itr = _conditionList.iterator(); |
| 89 |
0 |
String condition = null; |
| 90 |
0 |
while( itr.hasNext() ) { |
| 91 |
0 |
condition = (String)itr.next(); |
| 92 |
0 |
if( PSMLUtil.isEvaluatable(condition, context) ) { |
| 93 |
0 |
return (String)_nextScenes.get( condition ); |
| 94 |
|
} |
| 95 |
|
} |
| 96 |
0 |
return (String)_nextScenes.get( null ); |
| 97 |
|
} |
| 98 |
|
} |