コード例 #1
0
ファイル: JQRServer.py プロジェクト: ExSickness/JQR_PHASE_1
def getServerResult(taskNum, data):
	if taskNum == 1:
		return float(data[0]) + float(data[1])  # Sol.AddTwoNumbers(data[0], data[1])
	elif taskNum == 2:
		return float(data[0]) / float(data[1])#Sol.DivideTwoNumbers(data[0], data[1])
	elif taskNum == 3:
		return float(data[0]) * float(data[0])#Sol.MultiplyTwoNumbers(data[0], data[1])
	elif taskNum == 4:
		return float(data[0]) - float(data[1])#Sol.SubtractTwoNumbers(data[0], data[1])
	elif taskNum == 5:
		return float(data[0]) % float(data[1])#Sol.GetRemainder(data[0], data[1])
	elif taskNum == 6:
		for boardCount in range(0, data[0]):
			retVal = Sol.GenerateBoard(data[1], data[2], "./Boards/BOARD"+str(boardCount))
			if (retVal == -1):
				print("FAILED TO GENERATE BOARD {}".format(boardCount))
				return "FAIL"
		return "SUCCESS"
	elif taskNum == 7:
		retVal = Sol.FireRound(data[0], data[1], getBoardDimesions("./Boards/BOARD0")['COLS'], "./Boards/BOARD0")
		if retVal == 1:
			return "FIRED SHOT HIT"
		elif retVal == 0:
			return "FIRED: SHOT MISSED"
		elif retVal == -1:
			return "FAILED TO FIRE IN MODULE"
		else:
			return "FAIL"
コード例 #2
0
ファイル: JQRServer.py プロジェクト: ExSickness/JQR_PHASE_1
	def handle(self):
		retVal = { "TASKMSG": "", "TASKDATA": ''}
		failedTask = 0

		result = self.login()

		if( result == "SUCCESS"):
		#Send task to client
			for taskNum in range(1, len(JQRTask)+1):
				print("----------------------------")
				print ("SEND TASK {} of {}".format(taskNum, len(JQRTask)))

				if taskNum == 6:
					retVal = self.processTask(taskNum, 25, 10)
				elif taskNum == 7: 
					RowAndCol = {'ROWS': -1, 'COLS': -1}
					RowAndCol = getBoardDimesions("./Boards/BOARD0")
					retVal = self.processTask(taskNum, 5000,1, RowAndCol['ROWS'], RowAndCol['COLS'])
				else:
					retVal = self.processTask(taskNum, 5000, 1)

				self.sendTaskMessage(retVal['TASKMSG'])
				self.sendTaskData(taskNum, retVal['TASKDATA'])
				if(self.validateResponse(taskNum, retVal['TASKDATA']) == "FAIL"):
					failedTask += 1
		
			print("----------------------------")
			print("JQR COMPLETE")
		return
コード例 #3
0
ファイル: JQRServer.py プロジェクト: Derfador1/JQR_PHASE_1
 def processTask(self, taskNum, maxValue = 1, minValue = 1, nRows = 0, nCols = 0):
     retVal = { "TASKMSG": "", "TASKDATA": '', "EXPECTEDRESLUT":  ''}
     RowAndCol = getBoardDimesions("./Boards/BOARD0")
     print("ROWS: {} COLS: {}".format(nRows, nCols))
     retVal = GetTask(taskNum, maxValue, minValue, RowAndCol['ROWS'], RowAndCol['COLS'])
     print(retVal["TASKMSG"])
     return retVal