op.setReward(req.getParameter("reward"+op.getId()));
MogabalGameDao.updateMogabalGameEventOption(op, session);
}
//if add option add it and trigger editing
if (req.getParameter("addOptionSubmit")!=null) {
MogabalEventOptionHiber opt=new MogabalEventOptionHiber();
opt.setText("");
opt.setEval(0);
opt.setHint("");
opt.setReward("");
if (req.getParameter("modifyQuizEvent")==null)
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
MogabalGameDao.persistMogabalGameEventOption(opt, session);
mh.getOptions().add(opt);
MogabalGameDao.updateMogabalGameEvent(mh, session);
try {
res.sendRedirect("authMAGOBAL.do?id="+g.getId()+"&modifyQuestionEvent="+mh.getId()+"&jsp_insertNewQEvent=1&jsp_insertNewEvent=1");
} catch (Exception e) {
}
MessageBean.setMyMessage(req, "Game content updated, new option inserted.");
} else {
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyQuizEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
}
//if there is ID change request.. do it last
if (req.getParameter("modifyQuizEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change game over event
if (req.getParameter("insertGameOver")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyGameOverEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyGameOverEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_GAME_OVER);
mh.setGame(g);
if (req.getParameter("modifyGameOverEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyGameOverEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
//if there is ID change request.. do it last
if (req.getParameter("modifyGameOverEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change simple event
if (req.getParameter("insertSimple")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifySimpleEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifySimpleEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_SIMPLE);
mh.setGame(g);
if (req.getParameter("modifySimpleEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
mh.setReward(req.getParameter("qreward"));
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifySimpleEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
//if there is ID change request.. do it last
if (req.getParameter("modifySimpleEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change null event
if (req.getParameter("insertNull")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyNullEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyNullEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_NULL);
mh.setGame(g);
if (req.getParameter("modifyNullEvent")==null) mh.setId(req.getParameter("qid"));
mh.setInPublicRepository(false);
mh.setCellType(req.getParameter("qcelltype"));
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyNullEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
//if there is ID change request.. do it last
if (req.getParameter("modifyNullEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change multimedia event
if (req.getParameter("insertMultimedia")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyMMEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyMMEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_MULTIMEDIA);
mh.setGame(g);
if (req.getParameter("modifyMMEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
mh.setMultimediaResource(req.getParameter("qresource"));
//forward
mh.setForward(null);
try {
mh.setForward(MogabalGameDao.findMagobalGameEvent(req.getParameter("qreward"), session));
} catch (Exception e) {
}
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyMMEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
//if there is ID change request.. do it last
if (req.getParameter("modifyMMEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change decision tree event
if (req.getParameter("insertDecTree")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyDecTreeEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyDecTreeEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_DECISION_TREE);
mh.setGame(g);
if (req.getParameter("modifyDecTreeEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
//fill all options
Set<MogabalEventOptionHiber> opts=mh.getOptions();
for (MogabalEventOptionHiber op:opts) {
op.setText(req.getParameter("text"+op.getId()));
try {
op.setEval(Integer.parseInt(req.getParameter("value"+op.getId())));
} catch (Exception e) {
}
op.setHint(req.getParameter("hint"+op.getId()));
op.setReward(req.getParameter("reward"+op.getId()));
//forward
op.setForward(null);
try {
op.setForward(MogabalGameDao.findMagobalGameEvent(req.getParameter("forward"+op.getId()), session));
} catch (Exception e) {
}
MogabalGameDao.updateMogabalGameEventOption(op, session);
}
//if add option add it and trigger editing
if (req.getParameter("addOptionSubmit")!=null) {
MogabalEventOptionHiber opt=new MogabalEventOptionHiber();
opt.setText("");
opt.setEval(0);
opt.setHint("");
opt.setReward("");
opt.setForward(null);
if (req.getParameter("modifyDecTreeEvent")==null)
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
MogabalGameDao.persistMogabalGameEventOption(opt, session);
mh.getOptions().add(opt);
MogabalGameDao.updateMogabalGameEvent(mh, session);
try {
res.sendRedirect("authMAGOBAL.do?id="+g.getId()+"&modifyDecTreeEvent="+mh.getId()+"&jsp_insertNewDTEvent=1&jsp_insertNewEvent=1");
} catch (Exception e) {
}
MessageBean.setMyMessage(req, "Game content updated, new option inserted.");
} else {
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyDecTreeEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
}
//if there is ID change request.. do it last
if (req.getParameter("modifyDecTreeEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change conditional decision tree event
if (req.getParameter("insertCondDecTree")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyCondDecTreeEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyCondDecTreeEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_CONDITIONAL_DECISION_TREE);
mh.setGame(g);
if (req.getParameter("modifyCondDecTreeEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
//fill all options
Set<MogabalEventOptionHiber> opts=mh.getOptions();
for (MogabalEventOptionHiber op:opts) {
op.setText(req.getParameter("text"+op.getId()));
try {
op.setEval(Integer.parseInt(req.getParameter("value"+op.getId())));
} catch (Exception e) {
}
op.setHint(req.getParameter("hint"+op.getId()));
op.setReward(req.getParameter("reward"+op.getId()));
op.setCondition(req.getParameter("condition"+op.getId()));
//forward
op.setForward(null);
try {
op.setForward(MogabalGameDao.findMagobalGameEvent(req.getParameter("forward"+op.getId()), session));
} catch (Exception e) {
}
MogabalGameDao.updateMogabalGameEventOption(op, session);
}
//if add option add it and trigger editing
if (req.getParameter("addOptionSubmit")!=null) {
MogabalEventOptionHiber opt=new MogabalEventOptionHiber();
opt.setText("");
opt.setEval(0);
opt.setHint("");
opt.setReward("");
opt.setCondition("");
opt.setForward(null);
if (req.getParameter("modifyCondDecTreeEvent")==null)
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
MogabalGameDao.persistMogabalGameEventOption(opt, session);
mh.getOptions().add(opt);
MogabalGameDao.updateMogabalGameEvent(mh, session);
try {
res.sendRedirect("authMAGOBAL.do?id="+g.getId()+"&modifyCondDecTreeEvent="+mh.getId()+"&jsp_insertNewCDTEvent=1&jsp_insertNewEvent=1");
} catch (Exception e) {
}
MessageBean.setMyMessage(req, "Game content updated, new option inserted.");
} else {
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyCondDecTreeEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
}
//if there is ID change request.. do it last
if (req.getParameter("modifyCondDecTreeEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change mini game event
if (req.getParameter("insertMiniGame")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyMGameEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyMGameEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_MINI_GAME);
mh.setGame(g);
if (req.getParameter("modifyMGameEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
mh.setText(req.getParameter("qtext"));
mh.setMiniGameName(req.getParameter("qgname"));
mh.setMiniGameResultype(req.getParameter("qrestype"));
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyMGameEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
//if there is ID change request.. do it last
if (req.getParameter("modifyMGameEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change conditional variable set event
if (req.getParameter("insertVarSet")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyVarSetEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyVarSetEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_VAR_SET);
mh.setGame(g);
if (req.getParameter("modifyVarSetEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
//forward
mh.setForward(null);
try {
mh.setForward(MogabalGameDao.findMagobalGameEvent(req.getParameter("qreward"), session));
} catch (Exception e) {
}
//fill all options
Set<MogabalEventOptionHiber> opts=mh.getOptions();
for (MogabalEventOptionHiber op:opts) {
op.setText("0");
try {
op.setText(""+Integer.parseInt(req.getParameter("text"+op.getId())));
} catch (Exception e) {
}
op.setEval(0);
try {
op.setEval(Integer.parseInt(req.getParameter("value"+op.getId())));
} catch (Exception e) {
}
MogabalGameDao.updateMogabalGameEventOption(op, session);
}
//if add option add it and trigger editing
if (req.getParameter("addOptionSubmit")!=null) {
MogabalEventOptionHiber opt=new MogabalEventOptionHiber();
opt.setText("");
opt.setEval(0);
if (req.getParameter("modifyVarSetEvent")==null)
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
MogabalGameDao.persistMogabalGameEventOption(opt, session);
mh.getOptions().add(opt);
MogabalGameDao.updateMogabalGameEvent(mh, session);
try {
res.sendRedirect("authMAGOBAL.do?id="+g.getId()+"&modifyVarSetEvent="+mh.getId()+"&jsp_insertNewVSEvent=1&jsp_insertNewEvent=1");
} catch (Exception e) {
}
MessageBean.setMyMessage(req, "Game content updated, new variable set row inserted.");
} else {
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyVarSetEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
}
//if there is ID change request.. do it last
if (req.getParameter("modifyVarSetEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//insert / change case tree event
if (req.getParameter("insertCase")!=null) {
MogabalEventHiber mh=new MogabalEventHiber();
if (req.getParameter("modifyCaseEvent")!=null) {
mh=MogabalGameDao.findMagobalGameEvent(req.getParameter("modifyCaseEvent"), session);
}
mh.setEventType(MogabalGameDao.EVENT_TYPE_CASE);
mh.setGame(g);
if (req.getParameter("modifyCaseEvent")==null) mh.setId(req.getParameter("qid"));
mh.setPublicRepositoryName(req.getParameter("repname"));
mh.setInPublicRepository(false);
if (mh.getPublicRepositoryName()!=null)
if (!mh.getPublicRepositoryName().equals(""))
if (!mh.getPublicRepositoryName().equals("null"))
mh.setInPublicRepository(true);
mh.setCellType(req.getParameter("qcelltype"));
mh.setText("0");
try {
mh.setText(""+Integer.parseInt(req.getParameter("qtext")));
} catch (Exception e) {
}
//fill all options
Set<MogabalEventOptionHiber> opts=mh.getOptions();
for (MogabalEventOptionHiber op:opts) {
//forward
op.setForward(null);
try {
op.setForward(MogabalGameDao.findMagobalGameEvent(req.getParameter("forward"+op.getId()), session));
} catch (Exception e) {
}
op.setEval(0);
try {
op.setEval(Integer.parseInt(req.getParameter("value"+op.getId())));
} catch (Exception e) {
}
MogabalGameDao.updateMogabalGameEventOption(op, session);
}
//if add option add it and trigger editing
if (req.getParameter("addOptionSubmit")!=null) {
MogabalEventOptionHiber opt=new MogabalEventOptionHiber();
opt.setForward(null);
opt.setEval(0);
if (req.getParameter("modifyCaseEvent")==null)
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
MogabalGameDao.persistMogabalGameEventOption(opt, session);
mh.getOptions().add(opt);
MogabalGameDao.updateMogabalGameEvent(mh, session);
try {
res.sendRedirect("authMAGOBAL.do?id="+g.getId()+"&modifyCaseEvent="+mh.getId()+"&jsp_insertNewCASEEvent=1&jsp_insertNewEvent=1");
} catch (Exception e) {
}
MessageBean.setMyMessage(req, "Game content updated, new case row inserted.");
} else {
MessageBean.setMyMessage(req, "Game content updated.");
if (req.getParameter("modifyCaseEvent")==null) {
MogabalGameDao.persistMogabalGameEventHiber(mh, session);
} else {
MogabalGameDao.updateMogabalGameEvent(mh, session);
}
}
//if there is ID change request.. do it last
if (req.getParameter("modifyVarSetEvent")!=null)
if (!mh.getId().equals(req.getParameter("qid")))
changeEventId(mh,req.getParameter("qid"),session,req);
}
//copy events!
if (req.getParameter("copyEvent")!=null) {
MogabalEventHiber currentEvent=new MogabalEventHiber();
currentEvent.setId("gm"+g.getId()+"_"+new Random().nextInt(1000)+"_copy");
currentEvent.setInPublicRepository(false);
currentEvent.setPublicRepositoryName("");
MogabalEventHiber copyEvent=MogabalGameDao.findMagobalGameEvent(req.getParameter("copyEvent"),session);
//persist & redirect
currentEvent.setForward(null);
currentEvent.setMiniGameName(copyEvent.getMiniGameName());
currentEvent.setMiniGameResultype(copyEvent.getMiniGameResultype());
currentEvent.setMultimediaResource(copyEvent.getMultimediaResource());
currentEvent.setReward(copyEvent.getReward());
currentEvent.setText(copyEvent.getText());
currentEvent.setVarSetString(copyEvent.getVarSetString());
currentEvent.setEventType(copyEvent.getEventType());
currentEvent.setGame(g);
MogabalGameDao.persistMogabalGameEventHiber(currentEvent,session);
Set<MogabalEventOptionHiber> optns=copyEvent.getOptions();
for (MogabalEventOptionHiber op : optns) {
MogabalEventOptionHiber newOne=new MogabalEventOptionHiber();
newOne.setText(op.getText());
newOne.setHint(op.getHint());
newOne.setReward(op.getReward());
newOne.setEval(op.getEval());
newOne.setCondition(op.getCondition());
newOne.setForward(null);
MogabalGameDao.persistMogabalGameEventOption(newOne,session);
currentEvent.getOptions().add(newOne);
MogabalGameDao.updateMogabalGameEventOption(newOne,session);
}