from core.template.item import Axis, Item, Material
from core.ui.gameplay import GameplayUi

from siege import game
from siege.io import DataStream
from siege.network import Message
from siege.world import World

researchDesk = Item(name="ResearchDesk", useTime=20)

researchDesk.craftable(
    category = "Basics",
    subcategory = "Surfaces",
    level = 2,
    experience = 30,
    materials = [
        Material('lumber', quantity=10),
        Material('paper', quantity=6),
        Material('oil_clot'),
        Material('feather')
    ]
)

researchDesk.placeable(floor_axis=Axis())

researchDesk.provideServices("research")


@researchDesk.hasEvent
def interact(player, entity, position):
    if player.uid == World.get().getPlayer().uid:
        GameplayUi.get().research.showWhileNearby(entity)
    else:
        game.network.getServer().send(player.networkId, DataStream(Message.RESEARCH_INTERACT))
