aboutsummaryrefslogtreecommitdiff
path: root/client/map/item_factory.gd
blob: e38ca1081215626ccb973c2ec62b07fee8e86336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Hurry Curry! - a game about cooking
# Copyright (C) 2025 Hurry Curry! contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
class_name ItemFactory
extends Object

class ItemName:
	var name: String
	var contents: Array
	
	func _init(raw_name: String):
		var c = Array(raw_name.split(":"))
		name = c[0]
		contents = c[1].split(",") if c.size() > 1 else []

static func produce(raw_name: String, owned_by: Node3D) -> Item:
	var item: Item = produce_inner(raw_name, owned_by)
	item.item_name = raw_name
	return item

static func produce_inner(raw_name: String, owned_by: Node3D) -> Item:
	var item = ItemName.new(raw_name)
	match item.name:
		"bun": return Bun.new(owned_by)
		"cheese": return Cheese.new(owned_by)
		"cooked-noodles": return GenericItem.new(owned_by, preload("res://map/items/cooked_noodles.tscn"))
		"sliced-cheese": return SlicedCheese.new(owned_by)
		"dirt": return GenericItem.new(owned_by, preload("res://map/items/dirt.tscn"))
		"sliced-bun": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun.tscn"))
		"sliced-bun-top": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun_top.tscn"))
		"sliced-bun-bottom": return GenericItem.new(owned_by, preload("res://map/items/sliced_bun_bottom.tscn"))
		"burned": return Burned.new(owned_by)
		"coconut": return GenericItem.new(owned_by, preload("res://map/items/coconut.tscn"))
		"dough": return GenericItem.new(owned_by, preload("res://map/items/dough.tscn"))
		"fish": return GenericItem.new(owned_by, preload("res://map/items/fish.tscn"))
		"flour": return GenericItem.new(owned_by, preload("res://map/items/flour.tscn"))
		"leek": return GenericItem.new(owned_by, preload("res://map/items/leek.tscn"))
		"mushroom": return GenericItem.new(owned_by, preload("res://map/items/mushroom.tscn"))
		"sliced-leek": return SlicedLeek.new(owned_by)
		"noodles": return GenericItem.new(owned_by, preload("res://map/items/noodles.tscn"))
		"rolled-dough": return GenericItem.new(owned_by, preload("res://map/items/rolled_dough.tscn"))
		"strawberry-mochi": return Mochi.new(owned_by, Color(.98, .70, .75))
		"nigiri": return Nigiri.new(owned_by)
		"steak": return GenericItem.new(owned_by, preload("res://map/items/steak.tscn"))
		"seared-steak": return GenericItem.new(owned_by, preload("res://map/items/seared_steak.tscn"))
		"patty": return GenericItem.new(owned_by, preload("res://map/items/patty.tscn"))
		"seared-patty": return GenericItem.new(owned_by, preload("res://map/items/seared_patty.tscn"))
		"rice": return GenericItem.new(owned_by, preload("res://map/items/rice.tscn"))
		"sliced-fish": return GenericItem.new(owned_by, preload("res://map/items/sliced_fish.tscn"))
		"strawberry": return Strawberry.new(owned_by)
		"tomato": return Tomato.new(owned_by) # TODO: move into choppable class / move code into cutting_board
		"sliced-tomato": return SlicedTomato.new(owned_by)
		"lettuce": return GenericItem.new(owned_by, preload("res://map/items/lettuce.tscn"))
		"sliced-lettuce": return SlicedLettuce.new(owned_by)
		"potato": return Potato.new(owned_by)
		"sliced-potato": return GenericItem.new(owned_by, preload("res://map/items/sliced_potato.tscn"))
		"dirty-plate": return Plate.new(owned_by, ["dirt"])

		"pot": return Pot.new(owned_by, item.contents)
		"basket": return Basket.new(owned_by, item.contents)
		"pan": return Pan.new(owned_by, item.contents)
		"foodprocessor": return FoodProcessor.new(owned_by, item.contents)
		"glass": return Glass.new(owned_by, item.contents)
		"plate": return Plate.new(owned_by, item.contents)
		
		"unknown-order": return GenericItem.new(owned_by, preload("res://map/items/unknown_order.tscn"))

		_: return UnknownItem.new(owned_by, raw_name)