Kotlin migration?
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Kotlin migration?
by jayands » 21 Jan 2019, 21:18
I understand that it would be a huge task to perform, but it doesn't all have to be at once, and, properly configured, Kotlin takes away a lot of the unnecessary boilerplate required by Java, making the code easier to understand and therefore debug.
consider the following class, MatchWinStreak:
It might help to point out that IntelliJ IDEA (and its derivatives, the Community Edition and Android Studio) can convert Java to Kotlin out of the box, as well, which should make some of it less painful to do.
consider the following class, MatchWinStreak:
- Code: Select all
package forge.achievement;
import forge.game.Game;
import forge.game.player.Player;
public class MatchWinStreak extends StreakAchievement {
public MatchWinStreak(int bronze0, int silver0, int gold0, int mythic0) {
super("MatchWinStreak", "Match Win Streak", null,
String.format("Win %d matches in a row", bronze0), bronze0,
String.format("Win %d matches in a row", silver0), silver0,
String.format("Win %d matches in a row", gold0), gold0,
String.format("Win %d matches in a row", mythic0), mythic0);
}
@Override
protected Boolean eval(Player player, Game game) {
if (game.getMatch().isMatchOver()) {
return game.getMatch().isWonBy(player.getLobbyPlayer());
}
return null;
}
}
- Code: Select all
package forge.achievement
import forge.game.Game
import forge.game.player.Player
class MatchWinStreak(bronze0: Int, silver0: Int, gold0: Int, mythic0: Int) : StreakAchievement("MatchWinStreak",
"Match Win Streak", null, "Win $bronze0 matches in a row", bronze0,
"Win $silver0 matches in a row", silver0, "Win $gold0 matches in a row",
gold0, "Win $mythic0 matches in a row", mythic0) {
override fun eval(player: Player, game: Game): Boolean? {
return if (game.match.isMatchOver) {
game.match.isWonBy(player.lobbyPlayer)
} else null
}
}
It might help to point out that IntelliJ IDEA (and its derivatives, the Community Edition and Android Studio) can convert Java to Kotlin out of the box, as well, which should make some of it less painful to do.
- jayands
- Posts: 1
- Joined: 05 Aug 2018, 08:13
- Has thanked: 0 time
- Been thanked: 0 time
Re: Kotlin migration?
by KrazyTheFox » 03 Feb 2019, 18:05
I personally would be all for this, but at least a few of the other developers have expressed disinterest in learning/using Kotlin for the project. For now, it's likely that it will stay vanilla Java.
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: KeithOvart and 79 guests