Skip to content

Commit 53759ac

Browse files
Adding prices and format legalities to the card object.
1 parent 8974a4e commit 53759ac

4 files changed

Lines changed: 122 additions & 1 deletion

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.magicthegathering</groupId>
66
<artifactId>javasdk</artifactId>
7-
<version>0.0.6</version>
7+
<version>0.0.7</version>
88
<packaging>jar</packaging>
99

1010
<name>${project.groupId}:${project.artifactId}</name>

src/main/java/io/magicthegathering/javasdk/resource/Card.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.magicthegathering.javasdk.resource;
22

33
import java.io.Serializable;
4+
import java.math.BigDecimal;
45

56
/**
67
* This file is part of mtgsdk.
@@ -53,6 +54,13 @@ public class Card implements Serializable {
5354
private String setName;
5455
private String[] printings;
5556
private String imageUrl;
57+
private Legality[] legalities;
58+
private BigDecimal priceHigh;
59+
private BigDecimal priceMid;
60+
private BigDecimal priceLow;
61+
private BigDecimal onlinePriceHigh;
62+
private BigDecimal onlinePriceMid;
63+
private BigDecimal onlinePriceLow;
5664

5765
public String getId() {
5866
return id;
@@ -373,4 +381,60 @@ public String getImageUrl() {
373381
public void setImageUrl(String imageUrl) {
374382
this.imageUrl = imageUrl;
375383
}
384+
385+
public Legality[] getLegalities() {
386+
return legalities;
387+
}
388+
389+
public void setLegalities(Legality[] legalities) {
390+
this.legalities = legalities;
391+
}
392+
393+
public BigDecimal getPriceHigh() {
394+
return priceHigh;
395+
}
396+
397+
public void setPriceHigh(BigDecimal priceHigh) {
398+
this.priceHigh = priceHigh;
399+
}
400+
401+
public BigDecimal getPriceMid() {
402+
return priceMid;
403+
}
404+
405+
public void setPriceMid(BigDecimal priceMid) {
406+
this.priceMid = priceMid;
407+
}
408+
409+
public BigDecimal getPriceLow() {
410+
return priceLow;
411+
}
412+
413+
public void setPriceLow(BigDecimal priceLow) {
414+
this.priceLow = priceLow;
415+
}
416+
417+
public BigDecimal getOnlinePriceHigh() {
418+
return onlinePriceHigh;
419+
}
420+
421+
public void setOnlinePriceHigh(BigDecimal onlinePriceHigh) {
422+
this.onlinePriceHigh = onlinePriceHigh;
423+
}
424+
425+
public BigDecimal getOnlinePriceMid() {
426+
return onlinePriceMid;
427+
}
428+
429+
public void setOnlinePriceMid(BigDecimal onlinePriceMid) {
430+
this.onlinePriceMid = onlinePriceMid;
431+
}
432+
433+
public BigDecimal getOnlinePriceLow() {
434+
return onlinePriceLow;
435+
}
436+
437+
public void setOnlinePriceLow(BigDecimal onlinePriceLow) {
438+
this.onlinePriceLow = onlinePriceLow;
439+
}
376440
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package io.magicthegathering.javasdk.resource;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* This file is part of mtgsdk.
7+
* https://github.com/MagicTheGathering/mtg-sdk-java
8+
* <p>
9+
* Licensed under the MIT license:
10+
* http://www.opensource.org/licenses/MIT-license
11+
* <p>
12+
* Created by thechucklingatom on 5/8/2017.
13+
* <p>
14+
* The Legality sub object in the card json object.
15+
*
16+
* @author thechucklingatom
17+
*
18+
*/
19+
public class Legality implements Serializable{
20+
private String format;
21+
private String legality;
22+
23+
public String getFormat() {
24+
return format;
25+
}
26+
27+
public void setFormat(String format) {
28+
this.format = format;
29+
}
30+
31+
public String getLegality() {
32+
return legality;
33+
}
34+
35+
public void setLegality(String legality) {
36+
this.legality = legality;
37+
}
38+
39+
@Override
40+
public boolean equals(Object o){
41+
if(o instanceof Legality){
42+
return ((Legality) o).getFormat().equals(format)
43+
&& ((Legality) o).getLegality().equals(legality);
44+
}else{
45+
return false;
46+
}
47+
}
48+
}

src/test/java/io/magicthegathering/javasdk/api/CardAPITest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.Assert.assertNull;
66
import static org.junit.Assert.assertTrue;
77
import io.magicthegathering.javasdk.resource.Card;
8+
import io.magicthegathering.javasdk.resource.Legality;
89

910
import java.util.ArrayList;
1011
import java.util.List;
@@ -89,4 +90,12 @@ public void testCardFilter(){
8990
testCard.setManaCost("{3}{U}{U}");
9091
assertTrue(CardAPI.getAllCards(filter).contains(testCard));
9192
}
93+
94+
@Test
95+
public void testLegality() {
96+
Legality testLegality = new Legality();
97+
testLegality.setFormat("Commander");
98+
testLegality.setLegality("Legal");
99+
assertEquals(testLegality, CardAPI.getCard(1).getLegalities()[0]);
100+
}
92101
}

0 commit comments

Comments
 (0)