diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index 39df5188011..9166a85c1a3 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -148,6 +148,11 @@
1.6-1
+
+ org.ocpsoft.prettytime
+ prettytime
+ 3.2.7.Final
+
diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
index e473497f6d1..bbbea1497f2 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
@@ -46,6 +46,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellRenderer;
+
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@@ -70,6 +73,8 @@ import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
+import org.ocpsoft.prettytime.PrettyTime;
+import org.ocpsoft.prettytime.units.JustNow;
/**
*
@@ -100,6 +105,18 @@ public class TablesPanel extends javax.swing.JPanel {
final JToggleButton[] filterButtons;
+ // time ago date time renderer
+ private PrettyTime timeAgoFormater = new PrettyTime();
+ TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ Date d = (Date)value;
+ label.setText(timeAgoFormater.format(d));
+ return label;
+ }
+ };
+
/**
* Creates new form TablesPanel
*/
@@ -117,6 +134,28 @@ public class TablesPanel extends javax.swing.JPanel {
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
+
+ // time ago column settings
+ // formater
+ timeAgoFormater.setLocale(Locale.ENGLISH);
+ JustNow jn = timeAgoFormater.getUnit(JustNow.class);
+ jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
+ // renderer
+ tableTables.getColumnModel().getColumn(TableTableModel.COLUMN_CREATED).setCellRenderer(timeAgoCellRenderer);
+ /* date sorter (not need, default is good - see getColumnClass)
+ activeTablesSorter.setComparator(TableTableModel.COLUMN_CREATED, new Comparator() {
+ @Override
+ public int compare(Date v1, Date v2) {
+ return v1.compareTo(v2);
+ }
+
+ });*/
+ // default sort by created date (last games from above)
+ ArrayList list = new ArrayList();
+ list.add(new RowSorter.SortKey(TableTableModel.COLUMN_CREATED, SortOrder.DESCENDING));
+ activeTablesSorter.setSortKeys(list);
+
+
TableUtil.setColumnWidthAndOrder(tableTables, DEFAULT_COLUMNS_WIDTH,
PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, PreferencesDialog.KEY_TABLES_COLUMNS_ORDER);
@@ -1286,11 +1325,15 @@ class TableTableModel extends AbstractTableModel {
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
+ public void TableModel() {
+ }
+
public void loadData(Collection tables) throws MageRemoteException {
this.tables = tables.toArray(new TableView[0]);
this.fireTableDataChanged();
}
+
@Override
public int getRowCount() {
return tables.length;
@@ -1319,7 +1362,7 @@ class TableTableModel extends AbstractTableModel {
case 6:
return tables[arg0].isPassworded() ? PASSWORDED : "";
case 7:
- return timeFormatter.format(tables[arg0].getCreateTime());
+ return tables[arg0].getCreateTime(); // use cell render, not format here
case 8:
return tables[arg0].getSkillLevel();
case 9:
@@ -1384,6 +1427,8 @@ class TableTableModel extends AbstractTableModel {
return Icon.class;
case COLUMN_SKILL:
return SkillLevel.class;
+ case COLUMN_CREATED:
+ return Date.class;
default:
return String.class;
}
diff --git a/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java b/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java
new file mode 100644
index 00000000000..cf24c13827a
--- /dev/null
+++ b/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of BetaSteward_at_googlemail.com.
+ */
+package mage.cards.b;
+
+import java.util.UUID;
+import mage.abilities.Ability;
+import mage.abilities.effects.ReplacementEffectImpl;
+import mage.cards.CardImpl;
+import mage.cards.CardSetInfo;
+import mage.constants.CardType;
+import mage.constants.Duration;
+import mage.constants.Outcome;
+import mage.game.Game;
+import mage.game.events.DamageEvent;
+import mage.game.events.GameEvent;
+import mage.players.Player;
+
+/**
+ *
+ * @author L_J
+ */
+public class BloodOfTheMartyr extends CardImpl {
+
+ public BloodOfTheMartyr(UUID ownerId, CardSetInfo setInfo) {
+ super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}{W}{W}");
+
+ // Until end of turn, if damage would be dealt to any creature, you may have that damage dealt to you instead.
+ this.getSpellAbility().addEffect(new BloodOfTheMartyrEffect());
+ }
+
+ public BloodOfTheMartyr(final BloodOfTheMartyr card) {
+ super(card);
+ }
+
+ @Override
+ public BloodOfTheMartyr copy() {
+ return new BloodOfTheMartyr(this);
+ }
+}
+
+class BloodOfTheMartyrEffect extends ReplacementEffectImpl {
+
+ public BloodOfTheMartyrEffect() {
+ super(Duration.EndOfTurn, Outcome.RedirectDamage);
+ staticText = "Until end of turn, if damage would be dealt to any creature, you may have that damage dealt to you instead";
+ }
+
+ public BloodOfTheMartyrEffect(final BloodOfTheMartyrEffect effect) {
+ super(effect);
+ }
+
+ @Override
+ public BloodOfTheMartyrEffect copy() {
+ return new BloodOfTheMartyrEffect(this);
+ }
+
+ @Override
+ public boolean checksEventType(GameEvent event, Game game) {
+ return event.getType() == GameEvent.EventType.DAMAGE_CREATURE;
+ }
+
+ @Override
+ public boolean apply(Game game, Ability source) {
+ return true;
+ }
+
+ @Override
+ public boolean replaceEvent(GameEvent event, Ability source, Game game) {
+ Player controller = game.getPlayer(source.getControllerId());
+ DamageEvent damageEvent = (DamageEvent) event;
+ if (controller != null) {
+ controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean applies(GameEvent event, Ability source, Game game) {
+ Player controller = game.getPlayer(source.getControllerId());
+ DamageEvent damageEvent = (DamageEvent) event;
+ return controller != null
+ && controller.chooseUse(outcome, "Would you like to have " + damageEvent.getAmount() + " damage dealt to you instead of " + game.getPermanentOrLKIBattlefield(damageEvent.getTargetId()).getLogName() + "?", source, game);
+ }
+}
diff --git a/Mage.Sets/src/mage/sets/Chronicles.java b/Mage.Sets/src/mage/sets/Chronicles.java
index 3bc1ca3905b..9672adc0727 100644
--- a/Mage.Sets/src/mage/sets/Chronicles.java
+++ b/Mage.Sets/src/mage/sets/Chronicles.java
@@ -68,6 +68,7 @@ public class Chronicles extends ExpansionSet {
cards.add(new SetCardInfo("Barl's Cage", 74, Rarity.RARE, mage.cards.b.BarlsCage.class));
cards.add(new SetCardInfo("Beasts of Bogardan", 45, Rarity.UNCOMMON, mage.cards.b.BeastsOfBogardan.class));
cards.add(new SetCardInfo("Blood Moon", 46, Rarity.RARE, mage.cards.b.BloodMoon.class));
+ cards.add(new SetCardInfo("Blood of the Martyr", 60, Rarity.UNCOMMON, mage.cards.b.BloodOfTheMartyr.class));
cards.add(new SetCardInfo("Bog Rats", 2, Rarity.COMMON, mage.cards.b.BogRats.class));
cards.add(new SetCardInfo("Book of Rass", 75, Rarity.RARE, mage.cards.b.BookOfRass.class));
cards.add(new SetCardInfo("Boomerang", 16, Rarity.COMMON, mage.cards.b.Boomerang.class));
diff --git a/Mage.Sets/src/mage/sets/TheDark.java b/Mage.Sets/src/mage/sets/TheDark.java
index 4561ec28467..087fec24d05 100644
--- a/Mage.Sets/src/mage/sets/TheDark.java
+++ b/Mage.Sets/src/mage/sets/TheDark.java
@@ -59,6 +59,7 @@ public class TheDark extends ExpansionSet {
cards.add(new SetCardInfo("Ball Lightning", 56, Rarity.RARE, mage.cards.b.BallLightning.class));
cards.add(new SetCardInfo("Barl's Cage", 93, Rarity.RARE, mage.cards.b.BarlsCage.class));
cards.add(new SetCardInfo("Blood Moon", 57, Rarity.RARE, mage.cards.b.BloodMoon.class));
+ cards.add(new SetCardInfo("Blood of the Martyr", 75, Rarity.RARE, mage.cards.b.BloodOfTheMartyr.class));
cards.add(new SetCardInfo("Bog Imp", 3, Rarity.COMMON, mage.cards.b.BogImp.class));
cards.add(new SetCardInfo("Bog Rats", 4, Rarity.COMMON, mage.cards.b.BogRats.class));
cards.add(new SetCardInfo("Bone Flute", 94, Rarity.UNCOMMON, mage.cards.b.BoneFlute.class));