Warmonger.kt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.sirekanian.acf.data
  2. import com.sirekanian.acf.WarmongerModel
  3. import com.sirekanian.acf.data.local.WarmongerEntity
  4. import com.sirekanian.acf.data.remote.WarmongerDto
  5. class Warmonger(
  6. val id: Int,
  7. val cyrillicName: String,
  8. val name: String,
  9. val notes: String,
  10. ) {
  11. companion object {
  12. fun fromDto(dto: WarmongerDto): Warmonger =
  13. Warmonger(
  14. id = 0, // TODO: 1202468796234411
  15. cyrillicName = dto.`0`,
  16. name = dto.`1`.ifEmpty { dto.`0` },
  17. notes = dto.`4`,
  18. )
  19. fun fromEntity(entity: WarmongerEntity): Warmonger =
  20. Warmonger(
  21. id = entity.rowid,
  22. cyrillicName = entity.cyrillicName,
  23. name = entity.name,
  24. notes = entity.notes,
  25. )
  26. fun toEntity(warmonger: Warmonger): WarmongerEntity =
  27. WarmongerEntity(
  28. rowid = warmonger.id,
  29. cyrillicName = warmonger.cyrillicName,
  30. name = warmonger.name,
  31. notes = warmonger.notes,
  32. tags = "" // TODO: 1202468796234411
  33. )
  34. fun toModel(warmonger: Warmonger, isCyrillic: Boolean): WarmongerModel =
  35. WarmongerModel(
  36. id = warmonger.id,
  37. title = if (isCyrillic) warmonger.cyrillicName else warmonger.name,
  38. description = warmonger.notes,
  39. )
  40. }
  41. }