rt

An obligatory Java Project
Log | Files | Refs | LICENSE

commit 3017c80348e3bcd54b25ff4f0be33f0060b03e3d
parent 7aa571f5db97d6cd61a28571724204ee8c49e6ab
Author: zerous Naveen Narayanan <zerous@nocebo.space>
Date:   Mon, 25 Nov 2019 17:04:43 +0100

Implement selChar() method

Diffstat:
Mservertask.java | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/servertask.java b/servertask.java @@ -40,11 +40,50 @@ public class servertask implements Runnable { } } + private synchronized boolean selChar(DataInputStream inputStr, DataOutputStream outputStr, int timeout) { + String message = ""; + int val = 0; + if (timeout == 0) { + try { + if (inputStr.available() > 0) { + message = inputStr.readUTF(); + if (util.isNumeric(message)) { + val = Integer.parseInt(message); + if (val < 4 && val > 0) { + System.out.println("inere val: " + val + player.getUname()); + if (pscript.assignUser(val,player,lock)) { + return true; + } + else + notifyClient(outputStr, + "Character already assigned\n" + + "Try again"); + } + else if (val == 4) { + notifyClient(outputStr,pscript.getAssignedUsers(lock)); + } + } else { + notifyClient(outputStr, + "Invalid input\n" + + "Try again\n"); + } + } + } catch (IOException ex) { + System.out.println("IOException " + ex); + } + } else if (timeout == 1) { + pscript.assignUser(0,player,lock); + return true; + } + return false; + } + private String[][] getChar(group g) { roundAvg = Math.round(g.getAvgscr()); System.out.println("dbg " + roundAvg); for (script s : server.Scripts) { if (roundAvg == s.getDlevel()) { + pscript = s; System.out.println("dbg " + s.getDlevel()); return s.getRoles(); }