Question: In this task you will be writing a function validate _ comprpg _ actions ( game , actions, player _ id ) . game is

In this task you will be writing a function validate_comprpg_actions(game, actions, player_id).
game is the Game object that stores the state of the game
actions is a list of actions representing the chosen action for each active character from a single player
player_id is the int of the current player
Your function should return a bool indicating whether the actions are valid in the context of the current game. That is, it should return True if all requirements for being a valid action are met and False if there is a requirement that has not been met.
Your function should validate that:
When the turn is greater than 0:
actions is a list.
actions has an appropriate number of actions (not exceeding the number of the player's active characters, can be fewer).
Each action is a tuple, with a valid action type and is of the appropriate length for that action type.
Each action is of the correct format - including types, length, and values (see Action Format).
Each action follows the rules for actions of that type (see What make an action valid).
That the combination of those actions is valid (e.g. not using the same item twice when the player only has one of that item, not attempting to have both active characters swap to the same character).
Each action is performed by one of the characters who is active at the start of the turn, and at most one action may be performed by each character.
The total cost of electricity for the actions must be less than or equal to the players available electricity.
You may assume your validation function will be only tested on turns greater than 0.
>>> game = Game([Player(0,[{'name': 'Java Judger', 'health': 14, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'Python Pal', 'health': 0, 'defence': 0, 'effects': [], 'defeated': True},{'name': 'Haskell Heroine', 'health': 13, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'Binary Bot', 'health': 20, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'HTML Hero', 'health': 11, 'defence': 0, 'effects': [], 'defeated': False}],17,17,['Java Judger'],[],1), Player(1,[{'name': 'Python Pal', 'health': 22, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'C Charmer', 'health': 13, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'Linux Legend', 'health': 4, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'Binary Bot', 'health': 12, 'defence': 0, 'effects': [], 'defeated': False},{'name': 'Network Ninja', 'health': 0, 'defence': 0, 'effects': [], 'defeated': True}],11,1,['Python Pal'],[],1)],38,[[('Haskell Heroine', 'defend', 'Recursion Rebuff', 2,0),('Python Pal', 'item', 'Screen Repair Kit')],[('Linux Legend', 'attack', 'Root Reckoning', 4,2,5,['Haskell Heroine', 'Python Pal']),('Binary Bot', 'item', 'Debugging Tool')],[('Haskell Heroine', 'attack', 'Lambda Lunge', 3,1,0,['Linux Legend']),('Python Pal', 'item', 'RAM Boost')],[('Linux Legend', 'attack', 'Kernel Kick', 4,1,3,['Python Pal']),('Binary Bot', 'swap', 'Network Ninja')],[('Haskell Heroine', 'swap', 'Java Judger')],[('Linux Legend', 'defend', 'Firewall', 2,0),('Network Ninja', 'attack', 'DDoS', 3,1,1,['Python Pal'])],[('Java Judger', 'swap', 'HTML Hero')],[('Linux Legend', 'defend', 'Firewall', 2,0),('Network Ninja', 'attack', 'DDoS', 3,1,1,['HTML Hero'])],[('HTML Hero', 'attack', 'CSS Crusade', 3,1,2,['Linux Legend']),('Python Pal', 'attack', 'Indentation Impact', 3,1,2,['Network Ninja'])],[('Linux Legend', 'defend', 'Firewall', 2,0),('Network Ninja', 'attack', 'DDoS', 3,1,1,['Python Pal'])],[('HTML Hero', 'attack', 'Entity Eruption', 2,2,2,['Linux Legend', 'Network Ninja']),('Python Pal', 'swap', 'Java Judger')],[('Linux Legend', 'defend', 'Firewall', 2,0),('Network Ninja', 'attack', 'Packet Sniffer', 1,2,0,['HTML Hero', 'Java Judger'])],[('HTML Hero', 'attack', 'Entity Eruption', 2,2,2,['Linux Legend', 'Network Ninja']),('Java Judger', 'swap', 'Binary Bot')],[('Linux Legend', 'swap', 'Python Pal')],[('HTML Hero', 'attack', 'CSS Crusade', 3,1,2,['Network Ninja']),('Binary Bot', 'swap', 'Python Pal')],[('Python Pal', 'defend', 'Try-except Tactics', 5,3),('Network Ninja', 'attack', 'Code Injection', 10,1,15,['Python Pal'])],[('HTML Hero', 'swap', 'Java Judger')],[('Python Pal', 'attack', 'Syntax Strike', 4,1,3,['Python Pal']),('Network Ninja', 'swap', 'C Charmer')],[('Java Judger', 'swap', 'Haskell Heroine')],[('Python Pal', 'defend', 'Try-except Tactics', 5,3),('C Charmer', 'attack', 'Pointer Pinch', 1,2,0,['Haskell Heroine', 'Python Pal'])],[('Haskell Heroine', 'swap', 'HTML Hero')],[('Python Pal', 'attack', 'Syntax Strike', 4,1,3,['HTML Hero']),('C Charmer', 'swap', 'Linux Legend')],[('HTML Hero', 'defend', 'Firewall', 2,0),('Python Pal', 'defen

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!