Skip to content

Commit

Permalink
version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
redruin1 committed Sep 19, 2023
1 parent 517a8d3 commit c0f156f
Show file tree
Hide file tree
Showing 23 changed files with 400 additions and 9 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

# 1.1.0
* Added a number of missing prototype objects that are blueprintable:
* `SimpleEntityWithOwner`
* `SimpleEntityWithForce`
* `PlayerPort`
* Fixed an issue where color settings were not recognized in the settings stage (#103)
* Fixed issue loading IndustrialRevolution modpack (regression) (#98)

## 1.0.6
Expand Down
4 changes: 2 additions & 2 deletions draftsman/_factorio_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# _factorio_version.py

__factorio_version__ = "1.1.88.0"
__factorio_version_info__ = (1, 1, 88, 0)
__factorio_version__ = "1.1.89.0"
__factorio_version_info__ = (1, 1, 89, 0)
4 changes: 2 additions & 2 deletions draftsman/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# version.py

__version__ = "1.0.6"
__version_info__ = (1, 0, 6)
__version__ = "1.1.0"
__version_info__ = (1, 1, 0)
3 changes: 2 additions & 1 deletion draftsman/compatibility/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ end
set_settings("bool-setting")
set_settings("int-setting")
set_settings("double-setting")
set_settings("string-setting")
set_settings("string-setting")
set_settings("color-setting")
Binary file modified draftsman/data/entities.pkl
Binary file not shown.
3 changes: 3 additions & 0 deletions draftsman/data/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@
gates = _data["gates"]
turrets = _data["turrets"]
radars = _data["radars"]
simple_entities_with_owner = _data["simple_entities_with_owner"]
simple_entities_with_force = _data["simple_entities_with_force"]
electric_energy_interfaces = _data["electric_energy_interfaces"]
linked_containers = _data["linked_containers"]
heat_interfaces = _data["heat_interfaces"]
linked_belts = _data["linked_belts"]
infinity_containers = _data["infinity_containers"]
infinity_pipes = _data["infinity_pipes"]
burner_generators = _data["burner_generators"]
player_ports = _data["player_ports"]
Binary file modified draftsman/data/items.pkl
Binary file not shown.
Binary file modified draftsman/data/mods.pkl
Binary file not shown.
Binary file modified draftsman/data/modules.pkl
Binary file not shown.
Binary file modified draftsman/data/recipes.pkl
Binary file not shown.
Binary file modified draftsman/data/signals.pkl
Binary file not shown.
Binary file modified draftsman/data/tiles.pkl
Binary file not shown.
9 changes: 9 additions & 0 deletions draftsman/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@
from draftsman.prototypes.gate import Gate, gates
from draftsman.prototypes.turret import Turret, turrets
from draftsman.prototypes.radar import Radar, radars
from draftsman.prototypes.simple_entity_with_owner import SimpleEntityWithOwner, simple_entities_with_owner
from draftsman.prototypes.simple_entity_with_force import SimpleEntityWithForce, simple_entities_with_force
from draftsman.prototypes.electric_energy_interface import ElectricEnergyInterface, electric_energy_interfaces
from draftsman.prototypes.linked_container import LinkedContainer, linked_containers
from draftsman.prototypes.heat_interface import HeatInterface, heat_interfaces
from draftsman.prototypes.linked_belt import LinkedBelt, linked_belts
from draftsman.prototypes.infinity_container import InfinityContainer, infinity_containers
from draftsman.prototypes.infinity_pipe import InfinityPipe, infinity_pipes
from draftsman.prototypes.burner_generator import BurnerGenerator, burner_generators
from draftsman.prototypes.player_port import PlayerPort, player_ports
# fmt: on


Expand Down Expand Up @@ -195,6 +198,10 @@ def new_entity(name, **kwargs):
return Turret(name, **kwargs)
if name in radars:
return Radar(name, **kwargs)
if name in simple_entities_with_owner:
return SimpleEntityWithOwner(name, **kwargs)
if name in simple_entities_with_force:
return SimpleEntityWithForce(name, **kwargs)
if name in electric_energy_interfaces:
return ElectricEnergyInterface(name, **kwargs)
if name in linked_containers:
Expand All @@ -209,5 +216,7 @@ def new_entity(name, **kwargs):
return InfinityPipe(name, **kwargs)
if name in burner_generators:
return BurnerGenerator(name, **kwargs)
if name in player_ports:
return PlayerPort(name, **kwargs)

raise InvalidEntityError("'{}'".format(name))
21 changes: 20 additions & 1 deletion draftsman/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,20 @@ def sort(target_list):
categorize_entities(data.raw["radar"], entities["radars"])
sort(entities["radars"])

# Simple Entities with Owner
entities["simple_entities_with_owner"] = []
categorize_entities(
data.raw["simple-entity-with-owner"], entities["simple_entities_with_owner"]
)
sort(entities["simple_entities_with_owner"])

# Simple Entities with Force
entities["simple_entities_with_force"] = []
categorize_entities(
data.raw["simple-entity-with-force"], entities["simple_entities_with_force"]
)
sort(entities["simple_entities_with_force"])

# Electric Energy Interfaces
entities["electric_energy_interfaces"] = []
categorize_entities(
Expand Down Expand Up @@ -962,6 +976,11 @@ def sort(target_list):
categorize_entities(data.raw["burner-generator"], entities["burner_generators"])
sort(entities["burner_generators"])

# Player Ports
entities["player_ports"] = []
categorize_entities(data.raw["player-port"], entities["player_ports"])
sort(entities["player_ports"])

raw_order = get_order(unordered_entities_raw, *sort_tuple)
entities["raw"] = OrderedDict()
for name in raw_order:
Expand Down Expand Up @@ -1545,7 +1564,7 @@ def update(verbose=False, path=None, show_logs=False, no_mods=False, report=None
internal_folder=mod_folder,
version=mod_version,
archive=archive,
location=location.replace("\\", "/"), # Make sure forward slashes
location=location.replace("\\", "/"), # Make sure forward slashes
info=mod_info,
files=files,
data=mod_data,
Expand Down
29 changes: 29 additions & 0 deletions draftsman/prototypes/player_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# player_port.py

from draftsman.classes.entity import Entity
from draftsman.warning import DraftsmanWarning

from draftsman.data import entities
from draftsman.data.entities import player_ports

import warnings


class PlayerPort(Entity):
"""
A constructable respawn point typically used in scenarios.
"""

_exports = {}
_exports.update(Entity._exports)

def __init__(self, name=player_ports[0], **kwargs):
# type: (str, **dict) -> None
super(PlayerPort, self).__init__(name, player_ports, **kwargs)

for unused_arg in self.unused_args:
warnings.warn(
"{} has no attribute '{}'".format(type(self), unused_arg),
DraftsmanWarning,
stacklevel=2,
)
60 changes: 60 additions & 0 deletions draftsman/prototypes/simple_entity_with_force.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# simple_entity_with_force.py

from draftsman.classes.entity import Entity
from draftsman.warning import DraftsmanWarning

from draftsman.data import entities
from draftsman.data.entities import simple_entities_with_force

import warnings


class SimpleEntityWithForce(Entity):
"""
A generic entity associated with a team of players.
"""

_exports = {}
_exports.update(Entity._exports)
_exports.update(
{
"variation": {
"format": "int",
"description": "Graphical variation of the entity",
"required": lambda x: x is not None,
},
}
)

def __init__(self, name=simple_entities_with_force[0], **kwargs):
# type: (str, **dict) -> None
super(SimpleEntityWithForce, self).__init__(
name, simple_entities_with_force, **kwargs
)

self.variation = 1
if "variation" in kwargs:
self.variation = kwargs["variation"]
self.unused_args.pop("variation")

for unused_arg in self.unused_args:
warnings.warn(
"{} has no attribute '{}'".format(type(self), unused_arg),
DraftsmanWarning,
stacklevel=2,
)

@property
def variation(self):
# type: () -> int
"""
The number representing the graphical variation of the entity.
:type: ``int``
"""
return self._variation

@variation.setter
def variation(self, value):
# type: (int) -> None
self._variation = value
60 changes: 60 additions & 0 deletions draftsman/prototypes/simple_entity_with_owner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# simple_entity_with_owner.py

from draftsman.classes.entity import Entity
from draftsman.warning import DraftsmanWarning

from draftsman.data import entities
from draftsman.data.entities import simple_entities_with_owner

import warnings


class SimpleEntityWithOwner(Entity):
"""
A generic entity owned by some other entity.
"""

_exports = {}
_exports.update(Entity._exports)
_exports.update(
{
"variation": {
"format": "int",
"description": "Graphical variation of the entity",
"required": lambda x: x is not None,
},
}
)

def __init__(self, name=simple_entities_with_owner[0], **kwargs):
# type: (str, **dict) -> None
super(SimpleEntityWithOwner, self).__init__(
name, simple_entities_with_owner, **kwargs
)

self.variation = 1
if "variation" in kwargs:
self.variation = kwargs["variation"]
self.unused_args.pop("variation")

for unused_arg in self.unused_args:
warnings.warn(
"{} has no attribute '{}'".format(type(self), unused_arg),
DraftsmanWarning,
stacklevel=2,
)

@property
def variation(self):
# type: () -> int
"""
The number representing the graphical variation of the entity.
:type: ``int``
"""
return self._variation

@variation.setter
def variation(self, value):
# type: (int) -> None
self._variation = value
47 changes: 47 additions & 0 deletions test/entities/test_player_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# test_player_port.py
# -*- encoding: utf-8 -*-

from __future__ import unicode_literals

from draftsman.entity import PlayerPort, player_ports
from draftsman.error import InvalidEntityError
from draftsman.warning import DraftsmanWarning

import sys

if sys.version_info >= (3, 3): # pragma: no coverage
import unittest
else: # pragma: no coverage
import unittest2 as unittest


class PlayerPortTesting(unittest.TestCase):
def test_contstructor_init(self):
turret = PlayerPort()

with self.assertWarns(DraftsmanWarning):
PlayerPort(unused_keyword="whatever")

with self.assertRaises(InvalidEntityError):
PlayerPort("this is not a player port")

def test_mergable_with(self):
port1 = PlayerPort("player-port")
port2 = PlayerPort("player-port", tags={"some": "stuff"})

self.assertTrue(port1.mergable_with(port1))

self.assertTrue(port1.mergable_with(port2))
self.assertTrue(port2.mergable_with(port1))

port2.tile_position = (1, 1)
self.assertFalse(port1.mergable_with(port2))

def test_merge(self):
port1 = PlayerPort("player-port")
port2 = PlayerPort("player-port", tags={"some": "stuff"})

port1.merge(port2)
del port2

self.assertEqual(port1.tags, {"some": "stuff"})
Loading

0 comments on commit c0f156f

Please sign in to comment.