1 | package edu.ucsb.cs156.happiercows.entities; | |
2 | ||
3 | import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | import edu.ucsb.cs156.happiercows.strategies.CowHealthUpdateStrategies; | |
5 | import lombok.AllArgsConstructor; | |
6 | import lombok.Builder; | |
7 | import lombok.Data; | |
8 | import lombok.NoArgsConstructor; | |
9 | ||
10 | import javax.persistence.*; | |
11 | import java.time.LocalDate; | |
12 | import java.util.List; | |
13 | ||
14 | ||
15 | ||
16 | @Data | |
17 | @AllArgsConstructor | |
18 | @NoArgsConstructor | |
19 | @Builder | |
20 | @Entity(name = "commons") | |
21 | public class Commons { | |
22 | @Id | |
23 | @GeneratedValue(strategy = GenerationType.IDENTITY) | |
24 | private long id; | |
25 | ||
26 | private String name; | |
27 | private double cowPrice; | |
28 | private double milkPrice; | |
29 | private double startingBalance; | |
30 | private LocalDate startingDate; | |
31 | private LocalDate lastDate; | |
32 | private boolean showLeaderboard; | |
33 | | |
34 | private int capacityPerUser; | |
35 | private int carryingCapacity; | |
36 | private double degradationRate; | |
37 | ||
38 | // these defaults match old behavior | |
39 | @Enumerated(EnumType.STRING) | |
40 | @Builder.Default | |
41 | private CowHealthUpdateStrategies belowCapacityHealthUpdateStrategy = CowHealthUpdateStrategies.DEFAULT_BELOW_CAPACITY; | |
42 | @Enumerated(EnumType.STRING) | |
43 | @Builder.Default | |
44 | private CowHealthUpdateStrategies aboveCapacityHealthUpdateStrategy = CowHealthUpdateStrategies.DEFAULT_ABOVE_CAPACITY; | |
45 | ||
46 | ||
47 | @OneToMany(mappedBy = "commons", cascade = CascadeType.REMOVE) | |
48 | @JsonIgnore | |
49 | private List<UserCommons> joinedUsers; | |
50 | ||
51 | public boolean gameInProgress() { | |
52 | LocalDate today = LocalDate.now(); | |
53 |
3
1. gameInProgress : negated conditional → KILLED 2. gameInProgress : negated conditional → KILLED 3. gameInProgress : replaced boolean return with true for edu/ucsb/cs156/happiercows/entities/Commons::gameInProgress → KILLED |
return ((startingDate.isBefore(today) || startingDate.isEqual(today)) |
54 |
2
1. gameInProgress : negated conditional → KILLED 2. gameInProgress : negated conditional → KILLED |
&& (lastDate.isAfter(today) || lastDate.isEqual(today))); |
55 | } | |
56 | ||
57 | } | |
Mutations | ||
53 |
1.1 2.2 3.3 |
|
54 |
1.1 2.2 |