Skip to content

Commit cb17954

Browse files
committed
refactor: Refactoring class to keep serializable class structure and add more challenge type
1 parent 20c9d30 commit cb17954

File tree

1 file changed

+71
-12
lines changed

1 file changed

+71
-12
lines changed
Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,76 @@
11
package com.github.ilovegamecoding.intellijcodexp.model
22

3-
data class CodeXPChallenge(
4-
val id: String,
5-
val name: String,
6-
val category: Type,
7-
val description: String,
8-
val xp: Long,
9-
val goal: Long,
10-
var isCompleted: Boolean,
11-
val onCompletion: () -> Unit
12-
) {
3+
/**
4+
* CodeXPChallenge class
5+
* CodeXPChallenge is a class that represents a challenge. Challenges are used to track the progress of the user.
6+
*
7+
* @constructor Create empty CodeXPChallenge.
8+
*/
9+
class CodeXPChallenge() {
10+
/**
11+
* Type of challenge.
12+
*/
13+
var type: Int = -1
14+
15+
/**
16+
* Name of challenge.
17+
*/
18+
var name: String = ""
19+
20+
/**
21+
* Description of challenge.
22+
*/
23+
var description: String = ""
24+
25+
/**
26+
* Reward XP of challenge when completed.
27+
*/
28+
var rewardXP: Long = 0L
29+
30+
/**
31+
* Current value of challenge.
32+
*/
33+
var value: Long = 0L
34+
35+
/**
36+
* Goal of challenge.
37+
*/
38+
var goal: Long = 0L
39+
40+
/**
41+
* Constructor for CodeXPChallenge with all parameters.
42+
*/
43+
constructor(
44+
type: Int,
45+
name: String,
46+
description: String,
47+
rewardXP: Long,
48+
value: Long,
49+
goal: Long
50+
) : this() {
51+
this.type = type
52+
this.name = name
53+
this.description = description
54+
this.rewardXP = rewardXP
55+
this.value = value
56+
this.goal = goal
57+
}
58+
59+
/**
60+
* Type of challenge.
61+
*
62+
* !! Do not ever change the order of the enum values. If you want to add a new challenge type, add it to the end of the enum !!
63+
*/
1364
enum class Type {
14-
XP,
15-
ACTION
65+
TOTAL_XP,
66+
ACTION_COUNT,
67+
BUILD_COUNT,
68+
DEBUG_COUNT,
69+
RUN_COUNT,
70+
COMMIT_COUNT,
71+
PUSH_COUNT,
72+
MERGE_COUNT,
73+
PULL_COUNT,
74+
TYPING_COUNT,
1675
}
1776
}

0 commit comments

Comments
 (0)