From 5bde81be7d14da160e5c972a34acbd879832e952 Mon Sep 17 00:00:00 2001 From: Maxis010 Date: Sun, 16 Jul 2023 00:59:28 +0100 Subject: [PATCH 1/5] Added AstronomicalSign --- .../utils/time/AstronomicalSign.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/com/lilithsthrone/utils/time/AstronomicalSign.java diff --git a/src/com/lilithsthrone/utils/time/AstronomicalSign.java b/src/com/lilithsthrone/utils/time/AstronomicalSign.java new file mode 100644 index 0000000000..9a0ed97c01 --- /dev/null +++ b/src/com/lilithsthrone/utils/time/AstronomicalSign.java @@ -0,0 +1,77 @@ +package com.lilithsthrone.utils.time; + +import java.time.LocalDateTime; +import java.time.Month; + +public enum AstronomicalSign { + ARIES("aries", "♈", Month.MARCH, 21, Month.APRIL, 19), + TAURUS("taurus", "♉", Month.APRIL, 20, Month.MAY, 20), + GEMINI("gemini", "♊", Month.MAY, 21, Month.JUNE, 20), + CANCER("cancer", "♋", Month.JUNE, 21, Month.JULY, 22), + LEO("leo", "♌", Month.JULY, 23, Month.AUGUST, 22), + VIRGO("virgo", "♍", Month.AUGUST, 23, Month.SEPTEMBER, 22), + LIBRA("libra", "♎", Month.SEPTEMBER, 23, Month.OCTOBER, 21), + SCORPIO("scorpio", "♏", Month.OCTOBER, 22, Month.NOVEMBER, 21), + SAGITTARIUS("sagittarius", "♐", Month.NOVEMBER, 22, Month.DECEMBER, 21), + CAPRICORN("capricorn", "♑", Month.DECEMBER, 22, Month.JANUARY, 19), + AQUARIUS("aquarius", "♒", Month.JANUARY, 20, Month.FEBRUARY, 18), + PISCES("pisces", "♓", Month.FEBRUARY, 19, Month.MARCH, 20); + + private final String name; + private final String htmlDisplay; + private final Month startMonth; + private final int startDay; + private final Month endMonth; + private final int endDay; + + AstronomicalSign(String name, String htmlDisplay, Month startMonth, int startDay, Month endMonth, int endDay) { + this.name = name; + this.htmlDisplay = htmlDisplay; + this.startMonth = startMonth; + this.startDay = startDay; + this.endMonth = endMonth; + this.endDay = endDay; + } + + public String getName() { + return name; + } + + public String getHtmlDisplay() { + return htmlDisplay; + } + + public Month getStartMonth() { + return startMonth; + } + + public int getStartDay() { + return startDay; + } + + public Month getEndMonth() { + return endMonth; + } + + public int getEndDay() { + return endDay; + } + + @Override + public String toString() { + return getName(); + } + + public AstronomicalSign getSignFromDate(LocalDateTime dateTime) { + int day = dateTime.getDayOfMonth(); + Month month = dateTime.getMonth(); + + for (AstronomicalSign sign : AstronomicalSign.values()) { + if ((month == getStartMonth() && day>=getStartDay()) + || (month == getEndMonth() && day<=getEndDay())) { + return sign; + } + } + return null; // This should be impossible... + } +} From eef4b6f882aa1e2f0ce509bfe1acd43a4e2c1c39 Mon Sep 17 00:00:00 2001 From: Maxis010 Date: Sun, 16 Jul 2023 10:23:59 +0100 Subject: [PATCH 2/5] Added ChineseZodiac & ChineseCalender --- .../utils/time/ChineseCalender.java | 70 +++++++++++++++++++ .../utils/time/ChineseZodiac.java | 56 +++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 src/com/lilithsthrone/utils/time/ChineseCalender.java create mode 100644 src/com/lilithsthrone/utils/time/ChineseZodiac.java diff --git a/src/com/lilithsthrone/utils/time/ChineseCalender.java b/src/com/lilithsthrone/utils/time/ChineseCalender.java new file mode 100644 index 0000000000..ff4b4f9afa --- /dev/null +++ b/src/com/lilithsthrone/utils/time/ChineseCalender.java @@ -0,0 +1,70 @@ +package com.lilithsthrone.utils.time; + +import java.time.LocalDateTime; + +public enum ChineseCalender { + ONE(0, 2, 5), + TWO(1, 1, 24), + THREE(2, 2, 13), + FOUR(3, 2, 2), + FIVE(4, 1, 23), + SIX(5, 2, 10), + SEVEN(6, 1, 30), + EIGHT(7, 2, 17), + NINE(8, 2, 6), + TEN(9,1, 26), + ELEVEN(10, 2, 14), + TWELVE(11, 2, 4), + THIRTEEN(12, 1, 24), + FOURTEEN(13, 2, 11), + FIFTEEN(14, 1, 31), + SIXTEEN(15, 2, 19), + SEVENTEEN(16, 2, 8), + EIGHTEEN(17, 1, 27), + NINETEEN(18, 2, 15); + + private final int index; + private final int startMonth; + private final int startDay; + ChineseCalender(int index, int startMonth, int startDay) { + this.index = index; + this.startMonth = startMonth; + this.startDay = startDay; + } + + public int getIndex() { + return index; + } + + public int getStartMonth() { + return startMonth; + } + + public int getStartDay() { + return startDay; + } + + public static ChineseCalender getCycleFromIndex(int index) { + for(ChineseCalender cycle : ChineseCalender.values()) { + if (cycle.index == index) { + return cycle; + } + } + return null; + } + + public static int getCycleFromDate(LocalDateTime dateTime) { + int day = dateTime.getDayOfMonth(); + int month = dateTime.getMonthValue(); + // Remove 5 from the year to bring it inline with the chinese calendar https://en.wikipedia.org/wiki/Chinese_zodiac#Years + int index = (dateTime.getYear() - 5) % 19; + ChineseCalender cycle = getCycleFromIndex(index); + if (cycle == null) { + return -1; + } + if (month < cycle.getStartMonth() || (month == cycle.getStartMonth() && day < cycle.getStartDay())) { + return index - 1; + } + return index; + } +} diff --git a/src/com/lilithsthrone/utils/time/ChineseZodiac.java b/src/com/lilithsthrone/utils/time/ChineseZodiac.java new file mode 100644 index 0000000000..a06dc12437 --- /dev/null +++ b/src/com/lilithsthrone/utils/time/ChineseZodiac.java @@ -0,0 +1,56 @@ +package com.lilithsthrone.utils.time; + +import java.time.LocalDateTime; + +public enum ChineseZodiac { + RAT("rat", 0), + OX("ox", 1), + TIGER("tiger", 2), + RABBIT("rabbit", 3), + DRAGON("dragon", 4), + SNAKE("snake", 5), + HORSE("horse", 6), + GOAT("goat", 7), + MONKEY("monkey", 8), + ROOSTER("rooster", 9), + DOG("dog", 10), + PIG("pig", 11); + + private final String name; + private final int index; + + ChineseZodiac(String name, int index) { + this.name = name; + this.index = index; + } + + public String getName() { + return name; + } + + public int getIndex() { + return index; + } + + @Override + public String toString() { + return getName(); + } + + public ChineseZodiac getSignFromDate(LocalDateTime dateTime) { + // Remove 4 from the year to bring it inline with the chinese calendar https://en.wikipedia.org/wiki/Chinese_zodiac#Years + int signIndex = (dateTime.getYear() - 4) % 12; + if (ChineseCalender.getCycleFromDate(dateTime) != (dateTime.getYear() - 5) % 19) { + signIndex--; + if (signIndex < 0) { + signIndex = 11; + } + } + for(ChineseZodiac sign : ChineseZodiac.values()) { + if (signIndex == sign.index) { + return sign; + } + } + return null; // This should be impossible... + } +} From 07f276c804014e183ae7bb1117bd46eeb1952fc3 Mon Sep 17 00:00:00 2001 From: Maxis010 Date: Sun, 16 Jul 2023 11:17:57 +0100 Subject: [PATCH 3/5] Added Astronomical Sign & Chinese Zodiac to Character Info --- src/com/lilithsthrone/game/character/GameCharacter.java | 9 +++++++++ src/com/lilithsthrone/utils/time/AstronomicalSign.java | 6 +++--- src/com/lilithsthrone/utils/time/ChineseZodiac.java | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/lilithsthrone/game/character/GameCharacter.java b/src/com/lilithsthrone/game/character/GameCharacter.java index a6cdbf19ed..e5508a8e9a 100644 --- a/src/com/lilithsthrone/game/character/GameCharacter.java +++ b/src/com/lilithsthrone/game/character/GameCharacter.java @@ -291,6 +291,8 @@ import com.lilithsthrone.utils.XMLSaving; import com.lilithsthrone.utils.colours.Colour; import com.lilithsthrone.utils.colours.PresetColour; +import com.lilithsthrone.utils.time.AstronomicalSign; +import com.lilithsthrone.utils.time.ChineseZodiac; import com.lilithsthrone.world.AbstractWorldType; import com.lilithsthrone.world.Cell; import com.lilithsthrone.world.World; @@ -3652,6 +3654,13 @@ public String getCharacterInformationScreen(boolean includePerkTree) { +" on the "+this.getBirthdayString()+".")); } } + AstronomicalSign astronomicalSign = AstronomicalSign.getSignFromDate(this.getBirthday()); + infoScreenSB.append(UtilText.parse(this, + " [npc.HerPos] astronomical sign is " + +astronomicalSign.getName() + +" ("+astronomicalSign.getHtmlDisplay()+")" + +" and [npc.herPos] chinese zodiac animal is " + +ChineseZodiac.getSignFromDate(this.getBirthday()).getName()+".")); String relationships = this.getRelationshipStrTo(Main.game.getPlayer()); diff --git a/src/com/lilithsthrone/utils/time/AstronomicalSign.java b/src/com/lilithsthrone/utils/time/AstronomicalSign.java index 9a0ed97c01..6e1512e0ec 100644 --- a/src/com/lilithsthrone/utils/time/AstronomicalSign.java +++ b/src/com/lilithsthrone/utils/time/AstronomicalSign.java @@ -62,13 +62,13 @@ public String toString() { return getName(); } - public AstronomicalSign getSignFromDate(LocalDateTime dateTime) { + public static AstronomicalSign getSignFromDate(LocalDateTime dateTime) { int day = dateTime.getDayOfMonth(); Month month = dateTime.getMonth(); for (AstronomicalSign sign : AstronomicalSign.values()) { - if ((month == getStartMonth() && day>=getStartDay()) - || (month == getEndMonth() && day<=getEndDay())) { + if ((month == sign.getStartMonth() && day>=sign.getStartDay()) + || (month == sign.getEndMonth() && day<=sign.getEndDay())) { return sign; } } diff --git a/src/com/lilithsthrone/utils/time/ChineseZodiac.java b/src/com/lilithsthrone/utils/time/ChineseZodiac.java index a06dc12437..7974073a3f 100644 --- a/src/com/lilithsthrone/utils/time/ChineseZodiac.java +++ b/src/com/lilithsthrone/utils/time/ChineseZodiac.java @@ -37,7 +37,7 @@ public String toString() { return getName(); } - public ChineseZodiac getSignFromDate(LocalDateTime dateTime) { + public static ChineseZodiac getSignFromDate(LocalDateTime dateTime) { // Remove 4 from the year to bring it inline with the chinese calendar https://en.wikipedia.org/wiki/Chinese_zodiac#Years int signIndex = (dateTime.getYear() - 4) % 12; if (ChineseCalender.getCycleFromDate(dateTime) != (dateTime.getYear() - 5) % 19) { From 18a1f90652ee130ce760298e138254b686cd22b6 Mon Sep 17 00:00:00 2001 From: Maxis010 Date: Sun, 16 Jul 2023 13:35:56 +0100 Subject: [PATCH 4/5] Spelling error --- .../{ChineseCalender.java => ChineseCalendar.java} | 10 +++++----- src/com/lilithsthrone/utils/time/ChineseZodiac.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/com/lilithsthrone/utils/time/{ChineseCalender.java => ChineseCalendar.java} (83%) diff --git a/src/com/lilithsthrone/utils/time/ChineseCalender.java b/src/com/lilithsthrone/utils/time/ChineseCalendar.java similarity index 83% rename from src/com/lilithsthrone/utils/time/ChineseCalender.java rename to src/com/lilithsthrone/utils/time/ChineseCalendar.java index ff4b4f9afa..8a4843f4de 100644 --- a/src/com/lilithsthrone/utils/time/ChineseCalender.java +++ b/src/com/lilithsthrone/utils/time/ChineseCalendar.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -public enum ChineseCalender { +public enum ChineseCalendar { ONE(0, 2, 5), TWO(1, 1, 24), THREE(2, 2, 13), @@ -26,7 +26,7 @@ public enum ChineseCalender { private final int index; private final int startMonth; private final int startDay; - ChineseCalender(int index, int startMonth, int startDay) { + ChineseCalendar(int index, int startMonth, int startDay) { this.index = index; this.startMonth = startMonth; this.startDay = startDay; @@ -44,8 +44,8 @@ public int getStartDay() { return startDay; } - public static ChineseCalender getCycleFromIndex(int index) { - for(ChineseCalender cycle : ChineseCalender.values()) { + public static ChineseCalendar getCycleFromIndex(int index) { + for(ChineseCalendar cycle : ChineseCalendar.values()) { if (cycle.index == index) { return cycle; } @@ -58,7 +58,7 @@ public static int getCycleFromDate(LocalDateTime dateTime) { int month = dateTime.getMonthValue(); // Remove 5 from the year to bring it inline with the chinese calendar https://en.wikipedia.org/wiki/Chinese_zodiac#Years int index = (dateTime.getYear() - 5) % 19; - ChineseCalender cycle = getCycleFromIndex(index); + ChineseCalendar cycle = getCycleFromIndex(index); if (cycle == null) { return -1; } diff --git a/src/com/lilithsthrone/utils/time/ChineseZodiac.java b/src/com/lilithsthrone/utils/time/ChineseZodiac.java index 7974073a3f..cde4b27d95 100644 --- a/src/com/lilithsthrone/utils/time/ChineseZodiac.java +++ b/src/com/lilithsthrone/utils/time/ChineseZodiac.java @@ -40,7 +40,7 @@ public String toString() { public static ChineseZodiac getSignFromDate(LocalDateTime dateTime) { // Remove 4 from the year to bring it inline with the chinese calendar https://en.wikipedia.org/wiki/Chinese_zodiac#Years int signIndex = (dateTime.getYear() - 4) % 12; - if (ChineseCalender.getCycleFromDate(dateTime) != (dateTime.getYear() - 5) % 19) { + if (ChineseCalendar.getCycleFromDate(dateTime) != (dateTime.getYear() - 5) % 19) { signIndex--; if (signIndex < 0) { signIndex = 11; From dacfe827dbd5e018a9f2690b2680235aaf3b936c Mon Sep 17 00:00:00 2001 From: Maxis010 Date: Sun, 16 Jul 2023 13:40:47 +0100 Subject: [PATCH 5/5] Changed ChineseZodiac to match LT's variant --- src/com/lilithsthrone/utils/time/ChineseZodiac.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/lilithsthrone/utils/time/ChineseZodiac.java b/src/com/lilithsthrone/utils/time/ChineseZodiac.java index cde4b27d95..179ca87fd1 100644 --- a/src/com/lilithsthrone/utils/time/ChineseZodiac.java +++ b/src/com/lilithsthrone/utils/time/ChineseZodiac.java @@ -4,15 +4,15 @@ public enum ChineseZodiac { RAT("rat", 0), - OX("ox", 1), + COW("cow", 1), TIGER("tiger", 2), RABBIT("rabbit", 3), DRAGON("dragon", 4), - SNAKE("snake", 5), + LAMIA("lamia", 5), HORSE("horse", 6), GOAT("goat", 7), - MONKEY("monkey", 8), - ROOSTER("rooster", 9), + HARPY("harpy", 8), + DEMON("demon", 9), DOG("dog", 10), PIG("pig", 11);