# Path: webservice/service_func.py
# class func_error(Exception):
# class service_func:
# class default_func(service_func):
#     def __init__(self, message):
#     def __str__(self):
#     def __init__(self, func_path):
#     def check_server_key(self, args, server):
#     def init(self):
#     def execute(self, args, server):
#     def answer(self):
#     def get_meta(self):
#     def __init__(self, functions):
#     def answer(self):


from ..service_func import service_func, func_error, meta_arg


class add_point_to_team(service_func):
    def __init__(self):
        service_func.__init__(self, "/team/addpoint")
        self.name = "Add point to team"
        self.description = "Add point to a team corresponding by it team id"
        self.args.append(meta_arg("key", "Protection key", "none"))
        self.args.append(meta_arg("team", "Team Id", "none"))
        self.args.append(meta_arg("point", "Point to add", "none"))

    def execute(self, args, server):
        key = args["key"]
        point = int(args["point"])
        team = int(args["team"])

        if server.key == key:
            t = server.game_data.get_team(team)
            if t is not None:
                t.points += point
        else:

# Path: webservice/service_func.py
# class func_error(Exception):
# class service_func:
# class default_func(service_func):
#     def __init__(self, message):
#     def __str__(self):
#     def __init__(self, func_path):
#     def check_server_key(self, args, server):
#     def init(self):
#     def execute(self, args, server):
#     def answer(self):
#     def get_meta(self):
#     def __init__(self, functions):
#     def answer(self):


# Path: webservice/funcs/add_point_to_team.py
from ..service_func import service_func, func_error, meta_arg



class add_point_to_team(service_func):
    def __init__(self):
        service_func.__init__(self, "/team/addpoint")
        self.name = "Add point to team"
        self.description = "Add point to a team corresponding by it team id"
        self.args.append(meta_arg("key", "Protection key", "none"))
        self.args.append(meta_arg("team", "Team Id", "none"))
        self.args.append(meta_arg("point", "Point to add", "none"))

    def execute(self, args, server):
        key = args["key"]
        point = int(args["point"])
        team = int(args["team"])

        if server.key == key:
            t = server.game_data.get_team(team)
            if t is not None:
                t.points += point
        else:

            raise func_error("Invalid key")