Bug 626

Summary: Fail to select mode on laptops with no individual F1 and F2
Product: CS3343 2021/22 Group16 Greedy Snake Reporter: LI Ruoxin <ruoxinli3-c>
Component: Action PackageAssignee: Baron Qu <zhiyanqu2-c>
Status: RESOLVED FIXED    
Severity: normal CC: ruoxinli3-c
Priority: Normal    
Version: Ver 3.0   
Hardware: PC   
OS: Windows   

Description LI Ruoxin 2021-11-29 17:00:20 HKT
Steps to reproduce:
1. Run Main.java on laptops with no individual F1 and F2 keys (i.e. these two keys are functional keys as well)
2. Press fn+F1 or fn+F2 to select mode

Actual Results: Game does not switch to the selected mode

Expected Results: Game switches to the selected mode
Comment 1 Baron Qu 2021-12-05 11:28:29 HKT
Suspect the F1 key and F2 key are multiple function keys. Therefore, sometimes the computer does not take the F1 or F2 as input, but the computer shortcut command.
May just change the F1 key and F2 key to 1 key or 2 key. Or we change change the key to 'P' key or 'A' key.
Comment 2 Baron Qu 2021-12-05 11:29:17 HKT
*** Bug 624 has been marked as a duplicate of this bug. ***
Comment 3 Baron Qu 2021-12-05 11:29:29 HKT
*** Bug 625 has been marked as a duplicate of this bug. ***
Comment 4 LI Ruoxin 2021-12-05 18:27:20 HKT
Changed key F1 & F2 to key 1 & 2.
Code impletment:
public void keyPressed(KeyEvent e) {
		if (SConstant.SC_GAME_MODE_DEFAULT.equals(game.getMode())
				|| SConstant.SC_GAME_MODE_PlAYER.equals(game.getMode())) {
			keyLock = SConstant.SC_DEFAULT_KEYBOARD_LOCK;
		} else {
			keyLock = SConstant.SC_UPDATED_KEYBOARD_LOCK;
		}
		if (SConstant.SC_DEFAULT_KEYBOARD_LOCK.equals(keyLock)) {
			switch (e.getKeyCode()) {
			case KeyEvent.VK_1:
				Press1KeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_2:
				Press2KeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_DOWN:
				PressDownKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_LEFT:
				PressLeftKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_RIGHT:
				PressRightKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_UP:
				PressUpKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_SPACE:
				timer.start();
				break;
			}
		}
			
	}