diff --git a/deliverables/Coverage/coverage_1.JPG b/deliverables/Coverage/coverage_1.JPG new file mode 100644 index 0000000..3cb96bb Binary files /dev/null and b/deliverables/Coverage/coverage_1.JPG differ diff --git a/deliverables/Coverage/coverage_2.JPG b/deliverables/Coverage/coverage_2.JPG new file mode 100644 index 0000000..34fbd2b Binary files /dev/null and b/deliverables/Coverage/coverage_2.JPG differ diff --git a/deliverables/Coverage/htmlReport/css/coverage.css b/deliverables/Coverage/htmlReport/css/coverage.css new file mode 100644 index 0000000..cef7765 --- /dev/null +++ b/deliverables/Coverage/htmlReport/css/coverage.css @@ -0,0 +1,154 @@ +/* + * Copyright 2000-2021 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* { + margin: 0; + padding: 0; +} + +body { + background-color: #fff; + font-family: helvetica neue, tahoma, arial, sans-serif; + font-size: 82%; + color: #151515; +} + +h1 { + margin: 0.5em 0; + color: #010101; + font-weight: normal; + font-size: 18px; +} + +h2 { + margin: 0.5em 0; + color: #010101; + font-weight: normal; + font-size: 16px; +} + +a { + color: #1564C2; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +span.separator { + color: #9BA9BA; + padding-left: 5px; + padding-right: 5px; +} + +div.content { + width: 99%; +} + +table.coverageStats { + width: 100%; + border-collapse: collapse; +} + +table.overallStats { + width: 20%; +} + +table.coverageStats td, table.coverageStats th { + padding: 4px 2px; + border-bottom: 1px solid #ccc; +} + +table.coverageStats th { + background-color: #959BA4; + border: none; + font-weight: bold; + text-align: left; + color: #FFF; +} + +table.coverageStats th.coverageStat { + width: 15%; +} + +table.coverageStats th a { + color: #FFF; +} + +table.coverageStats th a:hover { + text-decoration: none; +} + +table.coverageStats th.sortedDesc a { + background: url(../img/arrowDown.gif) no-repeat 100% 2px; + padding-right: 20px; +} + +table.coverageStats th.sortedAsc a { + background: url(../img/arrowUp.gif) no-repeat 100% 2px; + padding-right: 20px; +} + +div.footer { + margin: 2em .5em; + font-size: 85%; + text-align: left; + line-height: 140%; +} + +code.sourceCode { + width: 100%; + border: 1px solid #ccc; + font: normal 12px 'Menlo', 'Bitstream Vera Sans Mono', 'Courier New', 'Courier', monospace; + white-space: pre; +} + +code.sourceCode b { + font-weight: normal; +} + +code.sourceCode span.number { + color: #151515; +} + +code.sourceCode .fc { + background-color: #cfc; +} + +code.sourceCode .pc { + background-color: #ffc; +} + +code.sourceCode .nc { + background-color: #fcc; +} + +.percent, .absValue { + font-size: 90%; +} + +.percent .green, .absValue .green { + color: #32cc32; +} + +.percent .red, .absValue .red { + color: #f00; +} + +.percent .totalDiff { + color: #3f3f3f; +} diff --git a/deliverables/Coverage/htmlReport/css/idea.min.css b/deliverables/Coverage/htmlReport/css/idea.min.css new file mode 100644 index 0000000..a8d5292 --- /dev/null +++ b/deliverables/Coverage/htmlReport/css/idea.min.css @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2021 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +Intellij Idea-like styling (c) Vasily Polovnyov +*/ + +.hljs { + color: #000; + background: #fff; +} + +.hljs-subst, +.hljs-title { + font-weight: normal; + color: #000; +} + +.hljs-comment, +.hljs-quote { + color: #808080; + font-style: italic; +} + +.hljs-meta { + color: #808000; +} + +.hljs-tag { + background: #efefef; +} + +.hljs-section, +.hljs-name, +.hljs-literal, +.hljs-keyword, +.hljs-selector-tag, +.hljs-type, +.hljs-selector-id, +.hljs-selector-class { + font-weight: bold; + color: #000080; +} + +.hljs-attribute, +.hljs-number, +.hljs-regexp, +.hljs-link { + font-weight: bold; + color: #0000ff; +} + +.hljs-number, +.hljs-regexp, +.hljs-link { + font-weight: normal; +} + +.hljs-string { + color: #008000; + font-weight: bold; +} + +.hljs-symbol, +.hljs-bullet, +.hljs-formula { + color: #000; + background: #d0eded; + font-style: italic; +} + +.hljs-doctag { + text-decoration: underline; +} + +.hljs-variable, +.hljs-template-variable { + color: #660e7a; +} + +.hljs-addition { + background: #baeeba; +} + +.hljs-deletion { + background: #ffc8bd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-ln-numbers { + display: block; + float: left; + width: 3em; + border-right: 1px solid #ccc; + font-style: normal; + text-align: right; + background-color: #eee; +} diff --git a/deliverables/Coverage/htmlReport/img/arrowDown.gif b/deliverables/Coverage/htmlReport/img/arrowDown.gif new file mode 100644 index 0000000..a4ac9b4 Binary files /dev/null and b/deliverables/Coverage/htmlReport/img/arrowDown.gif differ diff --git a/deliverables/Coverage/htmlReport/img/arrowUp.gif b/deliverables/Coverage/htmlReport/img/arrowUp.gif new file mode 100644 index 0000000..d488db0 Binary files /dev/null and b/deliverables/Coverage/htmlReport/img/arrowUp.gif differ diff --git a/deliverables/Coverage/htmlReport/index.html b/deliverables/Coverage/htmlReport/index.html new file mode 100644 index 0000000..14f1208 --- /dev/null +++ b/deliverables/Coverage/htmlReport/index.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..7e0d1b2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..a5b86da --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..6dbfa6f --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..af31910 --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/index_SORT_BY_LINE.html new file mode 100644 index 0000000..8ea3920 --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_LINE.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..b34f70c --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..44f562a --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..f7c944b --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..2b9cbe7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,782 @@ + + + + + + + Coverage Report > Summary + + + + + + +
+ + +

Overall Coverage Summary

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
all classes + + 50.6% + + + (45/89) + + + + 45.4% + + + (333/734) + + + + 43.2% + + + (664/1536) + + + + 36% + + + (1326/3684) + +
+ +
+

Coverage Breakdown

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + + 100% + + + (29/29) + +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (7/7) + +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+
+ + + + + + + diff --git a/deliverables/Coverage/htmlReport/js/highlight.min.js b/deliverables/Coverage/htmlReport/js/highlight.min.js new file mode 100644 index 0000000..e887315 --- /dev/null +++ b/deliverables/Coverage/htmlReport/js/highlight.min.js @@ -0,0 +1,1388 @@ +/* + Highlight.js 10.7.2 (00233d63) + License: BSD-3-Clause + Copyright (c) 2006-2021, Ivan Sagalaev + + BSD 3-Clause License + + Copyright (c) 2006-2021, Ivan Sagalaev. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * 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. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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. +*/ +var hljs=function(){"use strict";function e(t){ +return t instanceof Map?t.clear=t.delete=t.set=()=>{ +throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=()=>{ +throw Error("set is read-only") +}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((n=>{var i=t[n] +;"object"!=typeof i||Object.isFrozen(i)||e(i)})),t}var t=e,n=e;t.default=n +;class i{constructor(e){ +void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1} +ignoreMatch(){this.isMatchIgnored=!0}}function s(e){ +return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'") +}function a(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t] +;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const r=e=>!!e.kind +;class l{constructor(e,t){ +this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){ +this.buffer+=s(e)}openNode(e){if(!r(e))return;let t=e.kind +;e.sublanguage||(t=`${this.classPrefix}${t}`),this.span(t)}closeNode(e){ +r(e)&&(this.buffer+="")}value(){return this.buffer}span(e){ +this.buffer+=``}}class o{constructor(){this.rootNode={ +children:[]},this.stack=[this.rootNode]}get top(){ +return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){ +this.top.children.push(e)}openNode(e){const t={kind:e,children:[]} +;this.add(t),this.stack.push(t)}closeNode(){ +if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){ +for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)} +walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){ +return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t), +t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){ +"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{ +o._collapse(e)})))}}class c extends o{constructor(e){super(),this.options=e} +addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())} +addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const n=e.root +;n.kind=t,n.sublanguage=!0,this.add(n)}toHTML(){ +return new l(this,this.options).value()}finalize(){return!0}}function g(e){ +return e?"string"==typeof e?e:e.source:null} +const u=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,h="[a-zA-Z]\\w*",d="[a-zA-Z_]\\w*",f="\\b\\d+(\\.\\d+)?",p="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",m="\\b(0b[01]+)",b={ +begin:"\\\\[\\s\\S]",relevance:0},E={className:"string",begin:"'",end:"'", +illegal:"\\n",contains:[b]},x={className:"string",begin:'"',end:'"', +illegal:"\\n",contains:[b]},v={ +begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ +},w=(e,t,n={})=>{const i=a({className:"comment",begin:e,end:t,contains:[]},n) +;return i.contains.push(v),i.contains.push({className:"doctag", +begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),i +},y=w("//","$"),N=w("/\\*","\\*/"),R=w("#","$");var _=Object.freeze({ +__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:h,UNDERSCORE_IDENT_RE:d, +NUMBER_RE:f,C_NUMBER_RE:p,BINARY_NUMBER_RE:m, +RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", +SHEBANG:(e={})=>{const t=/^#![ ]*\// +;return e.binary&&(e.begin=((...e)=>e.map((e=>g(e))).join(""))(t,/.*\b/,e.binary,/\b.*/)), +a({className:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{ +0!==e.index&&t.ignoreMatch()}},e)},BACKSLASH_ESCAPE:b,APOS_STRING_MODE:E, +QUOTE_STRING_MODE:x,PHRASAL_WORDS_MODE:v,COMMENT:w,C_LINE_COMMENT_MODE:y, +C_BLOCK_COMMENT_MODE:N,HASH_COMMENT_MODE:R,NUMBER_MODE:{className:"number", +begin:f,relevance:0},C_NUMBER_MODE:{className:"number",begin:p,relevance:0}, +BINARY_NUMBER_MODE:{className:"number",begin:m,relevance:0},CSS_NUMBER_MODE:{ +className:"number", +begin:f+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?", +relevance:0},REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{className:"regexp", +begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[b,{begin:/\[/,end:/\]/, +relevance:0,contains:[b]}]}]},TITLE_MODE:{className:"title",begin:h,relevance:0 +},UNDERSCORE_TITLE_MODE:{className:"title",begin:d,relevance:0},METHOD_GUARD:{ +begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{ +"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{ +t.data._beginMatch!==e[1]&&t.ignoreMatch()}})});function k(e,t){ +"."===e.input[e.index-1]&&t.ignoreMatch()}function M(e,t){ +t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)", +e.__beforeBegin=k,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords, +void 0===e.relevance&&(e.relevance=0))}function O(e,t){ +Array.isArray(e.illegal)&&(e.illegal=((...e)=>"("+e.map((e=>g(e))).join("|")+")")(...e.illegal)) +}function A(e,t){if(e.match){ +if(e.begin||e.end)throw Error("begin & end are not supported with match") +;e.begin=e.match,delete e.match}}function L(e,t){ +void 0===e.relevance&&(e.relevance=1)} +const I=["of","and","for","in","not","or","if","then","parent","list","value"] +;function j(e,t,n="keyword"){const i={} +;return"string"==typeof e?s(n,e.split(" ")):Array.isArray(e)?s(n,e):Object.keys(e).forEach((n=>{ +Object.assign(i,j(e[n],t,n))})),i;function s(e,n){ +t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|") +;i[n[0]]=[e,B(n[0],n[1])]}))}}function B(e,t){ +return t?Number(t):(e=>I.includes(e.toLowerCase()))(e)?0:1} +function T(e,{plugins:t}){function n(t,n){ +return RegExp(g(t),"m"+(e.case_insensitive?"i":"")+(n?"g":""))}class i{ +constructor(){ +this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0} +addRule(e,t){ +t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]), +this.matchAt+=(e=>RegExp(e.toString()+"|").exec("").length-1)(e)+1}compile(){ +0===this.regexes.length&&(this.exec=()=>null) +;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(((e,t="|")=>{let n=0 +;return e.map((e=>{n+=1;const t=n;let i=g(e),s="";for(;i.length>0;){ +const e=u.exec(i);if(!e){s+=i;break} +s+=i.substring(0,e.index),i=i.substring(e.index+e[0].length), +"\\"===e[0][0]&&e[1]?s+="\\"+(Number(e[1])+t):(s+=e[0],"("===e[0]&&n++)}return s +})).map((e=>`(${e})`)).join(t)})(e),!0),this.lastIndex=0}exec(e){ +this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e) +;if(!t)return null +;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n] +;return t.splice(0,n),Object.assign(t,i)}}class s{constructor(){ +this.rules=[],this.multiRegexes=[], +this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){ +if(this.multiRegexes[e])return this.multiRegexes[e];const t=new i +;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))), +t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){ +return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){ +this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){ +const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex +;let n=t.exec(e) +;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{ +const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)} +return n&&(this.regexIndex+=n.position+1, +this.regexIndex===this.count&&this.considerAll()),n}} +if(e.compilerExtensions||(e.compilerExtensions=[]), +e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.") +;return e.classNameAliases=a(e.classNameAliases||{}),function t(i,r){const l=i +;if(i.isCompiled)return l +;[A].forEach((e=>e(i,r))),e.compilerExtensions.forEach((e=>e(i,r))), +i.__beforeBegin=null,[M,O,L].forEach((e=>e(i,r))),i.isCompiled=!0;let o=null +;if("object"==typeof i.keywords&&(o=i.keywords.$pattern, +delete i.keywords.$pattern), +i.keywords&&(i.keywords=j(i.keywords,e.case_insensitive)), +i.lexemes&&o)throw Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ") +;return o=o||i.lexemes||/\w+/, +l.keywordPatternRe=n(o,!0),r&&(i.begin||(i.begin=/\B|\b/), +l.beginRe=n(i.begin),i.endSameAsBegin&&(i.end=i.begin), +i.end||i.endsWithParent||(i.end=/\B|\b/), +i.end&&(l.endRe=n(i.end)),l.terminatorEnd=g(i.end)||"", +i.endsWithParent&&r.terminatorEnd&&(l.terminatorEnd+=(i.end?"|":"")+r.terminatorEnd)), +i.illegal&&(l.illegalRe=n(i.illegal)), +i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>a(e,{ +variants:null},t)))),e.cachedVariants?e.cachedVariants:S(e)?a(e,{ +starts:e.starts?a(e.starts):null +}):Object.isFrozen(e)?a(e):e))("self"===e?i:e)))),i.contains.forEach((e=>{t(e,l) +})),i.starts&&t(i.starts,r),l.matcher=(e=>{const t=new s +;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin" +}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end" +}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(l),l}(e)}function S(e){ +return!!e&&(e.endsWithParent||S(e.starts))}function P(e){const t={ +props:["language","code","autodetect"],data:()=>({detectedLanguage:"", +unknownLanguage:!1}),computed:{className(){ +return this.unknownLanguage?"":"hljs "+this.detectedLanguage},highlighted(){ +if(!this.autoDetect&&!e.getLanguage(this.language))return console.warn(`The language "${this.language}" you specified could not be found.`), +this.unknownLanguage=!0,s(this.code);let t={} +;return this.autoDetect?(t=e.highlightAuto(this.code), +this.detectedLanguage=t.language):(t=e.highlight(this.language,this.code,this.ignoreIllegals), +this.detectedLanguage=this.language),t.value},autoDetect(){ +return!(this.language&&(e=this.autodetect,!e&&""!==e));var e}, +ignoreIllegals:()=>!0},render(e){return e("pre",{},[e("code",{ +class:this.className,domProps:{innerHTML:this.highlighted}})])}};return{ +Component:t,VuePlugin:{install(e){e.component("highlightjs",t)}}}}const D={ +"after:highlightElement":({el:e,result:t,text:n})=>{const i=H(e) +;if(!i.length)return;const a=document.createElement("div") +;a.innerHTML=t.value,t.value=((e,t,n)=>{let i=0,a="";const r=[];function l(){ +return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset"}function c(e){ +a+=""}function g(e){("start"===e.event?o:c)(e.node)} +for(;e.length||t.length;){let t=l() +;if(a+=s(n.substring(i,t[0].offset)),i=t[0].offset,t===e){r.reverse().forEach(c) +;do{g(t.splice(0,1)[0]),t=l()}while(t===e&&t.length&&t[0].offset===i) +;r.reverse().forEach(o) +}else"start"===t[0].event?r.push(t[0].node):r.pop(),g(t.splice(0,1)[0])} +return a+s(n.substr(i))})(i,H(a),n)}};function C(e){ +return e.nodeName.toLowerCase()}function H(e){const t=[];return function e(n,i){ +for(let s=n.firstChild;s;s=s.nextSibling)3===s.nodeType?i+=s.nodeValue.length:1===s.nodeType&&(t.push({ +event:"start",offset:i,node:s}),i=e(s,i),C(s).match(/br|hr|img|input/)||t.push({ +event:"stop",offset:i,node:s}));return i}(e,0),t}const $={},U=e=>{ +console.error(e)},z=(e,...t)=>{console.log("WARN: "+e,...t)},K=(e,t)=>{ +$[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),$[`${e}/${t}`]=!0) +},G=s,V=a,W=Symbol("nomatch");return(e=>{ +const n=Object.create(null),s=Object.create(null),a=[];let r=!0 +;const l=/(^(<[^>]+>|\t|)+|\n)/gm,o="Could not find the language '{}', did you forget to load/include a language module?",g={ +disableAutodetect:!0,name:"Plain text",contains:[]};let u={ +noHighlightRe:/^(no-?highlight)$/i, +languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-", +tabReplace:null,useBR:!1,languages:null,__emitter:c};function h(e){ +return u.noHighlightRe.test(e)}function d(e,t,n,i){let s="",a="" +;"object"==typeof t?(s=e, +n=t.ignoreIllegals,a=t.language,i=void 0):(K("10.7.0","highlight(lang, code, ...args) has been deprecated."), +K("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"), +a=e,s=t);const r={code:s,language:a};M("before:highlight",r) +;const l=r.result?r.result:f(r.language,r.code,n,i) +;return l.code=r.code,M("after:highlight",l),l}function f(e,t,s,l){ +function c(e,t){const n=v.case_insensitive?t[0].toLowerCase():t[0] +;return Object.prototype.hasOwnProperty.call(e.keywords,n)&&e.keywords[n]} +function g(){null!=R.subLanguage?(()=>{if(""===M)return;let e=null +;if("string"==typeof R.subLanguage){ +if(!n[R.subLanguage])return void k.addText(M) +;e=f(R.subLanguage,M,!0,_[R.subLanguage]),_[R.subLanguage]=e.top +}else e=p(M,R.subLanguage.length?R.subLanguage:null) +;R.relevance>0&&(O+=e.relevance),k.addSublanguage(e.emitter,e.language) +})():(()=>{if(!R.keywords)return void k.addText(M);let e=0 +;R.keywordPatternRe.lastIndex=0;let t=R.keywordPatternRe.exec(M),n="";for(;t;){ +n+=M.substring(e,t.index);const i=c(R,t);if(i){const[e,s]=i +;if(k.addText(n),n="",O+=s,e.startsWith("_"))n+=t[0];else{ +const n=v.classNameAliases[e]||e;k.addKeyword(t[0],n)}}else n+=t[0] +;e=R.keywordPatternRe.lastIndex,t=R.keywordPatternRe.exec(M)} +n+=M.substr(e),k.addText(n)})(),M=""}function h(e){ +return e.className&&k.openNode(v.classNameAliases[e.className]||e.className), +R=Object.create(e,{parent:{value:R}}),R}function d(e,t,n){let s=((e,t)=>{ +const n=e&&e.exec(t);return n&&0===n.index})(e.endRe,n);if(s){if(e["on:end"]){ +const n=new i(e);e["on:end"](t,n),n.isMatchIgnored&&(s=!1)}if(s){ +for(;e.endsParent&&e.parent;)e=e.parent;return e}} +if(e.endsWithParent)return d(e.parent,t,n)}function m(e){ +return 0===R.matcher.regexIndex?(M+=e[0],1):(I=!0,0)}function b(e){ +const n=e[0],i=t.substr(e.index),s=d(R,e,i);if(!s)return W;const a=R +;a.skip?M+=n:(a.returnEnd||a.excludeEnd||(M+=n),g(),a.excludeEnd&&(M=n));do{ +R.className&&k.closeNode(),R.skip||R.subLanguage||(O+=R.relevance),R=R.parent +}while(R!==s.parent) +;return s.starts&&(s.endSameAsBegin&&(s.starts.endRe=s.endRe), +h(s.starts)),a.returnEnd?0:n.length}let E={};function x(n,a){const l=a&&a[0] +;if(M+=n,null==l)return g(),0 +;if("begin"===E.type&&"end"===a.type&&E.index===a.index&&""===l){ +if(M+=t.slice(a.index,a.index+1),!r){const t=Error("0 width match regex") +;throw t.languageName=e,t.badRule=E.rule,t}return 1} +if(E=a,"begin"===a.type)return function(e){ +const t=e[0],n=e.rule,s=new i(n),a=[n.__beforeBegin,n["on:begin"]] +;for(const n of a)if(n&&(n(e,s),s.isMatchIgnored))return m(t) +;return n&&n.endSameAsBegin&&(n.endRe=RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")), +n.skip?M+=t:(n.excludeBegin&&(M+=t), +g(),n.returnBegin||n.excludeBegin||(M=t)),h(n),n.returnBegin?0:t.length}(a) +;if("illegal"===a.type&&!s){ +const e=Error('Illegal lexeme "'+l+'" for mode "'+(R.className||"")+'"') +;throw e.mode=R,e}if("end"===a.type){const e=b(a);if(e!==W)return e} +if("illegal"===a.type&&""===l)return 1 +;if(L>1e5&&L>3*a.index)throw Error("potential infinite loop, way more iterations than matches") +;return M+=l,l.length}const v=N(e) +;if(!v)throw U(o.replace("{}",e)),Error('Unknown language: "'+e+'"') +;const w=T(v,{plugins:a});let y="",R=l||w;const _={},k=new u.__emitter(u);(()=>{ +const e=[];for(let t=R;t!==v;t=t.parent)t.className&&e.unshift(t.className) +;e.forEach((e=>k.openNode(e)))})();let M="",O=0,A=0,L=0,I=!1;try{ +for(R.matcher.considerAll();;){ +L++,I?I=!1:R.matcher.considerAll(),R.matcher.lastIndex=A +;const e=R.matcher.exec(t);if(!e)break;const n=x(t.substring(A,e.index),e) +;A=e.index+n}return x(t.substr(A)),k.closeAllNodes(),k.finalize(),y=k.toHTML(),{ +relevance:Math.floor(O),value:y,language:e,illegal:!1,emitter:k,top:R}}catch(n){ +if(n.message&&n.message.includes("Illegal"))return{illegal:!0,illegalBy:{ +msg:n.message,context:t.slice(A-100,A+100),mode:n.mode},sofar:y,relevance:0, +value:G(t),emitter:k};if(r)return{illegal:!1,relevance:0,value:G(t),emitter:k, +language:e,top:R,errorRaised:n};throw n}}function p(e,t){ +t=t||u.languages||Object.keys(n);const i=(e=>{const t={relevance:0, +emitter:new u.__emitter(u),value:G(e),illegal:!1,top:g} +;return t.emitter.addText(e),t})(e),s=t.filter(N).filter(k).map((t=>f(t,e,!1))) +;s.unshift(i);const a=s.sort(((e,t)=>{ +if(e.relevance!==t.relevance)return t.relevance-e.relevance +;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1 +;if(N(t.language).supersetOf===e.language)return-1}return 0})),[r,l]=a,o=r +;return o.second_best=l,o}const m={"before:highlightElement":({el:e})=>{ +u.useBR&&(e.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")) +},"after:highlightElement":({result:e})=>{ +u.useBR&&(e.value=e.value.replace(/\n/g,"
"))}},b=/^(<[^>]+>|\t)+/gm,E={ +"after:highlightElement":({result:e})=>{ +u.tabReplace&&(e.value=e.value.replace(b,(e=>e.replace(/\t/g,u.tabReplace))))}} +;function x(e){let t=null;const n=(e=>{let t=e.className+" " +;t+=e.parentNode?e.parentNode.className:"";const n=u.languageDetectRe.exec(t) +;if(n){const t=N(n[1]) +;return t||(z(o.replace("{}",n[1])),z("Falling back to no-highlight mode for this block.",e)), +t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>h(e)||N(e)))})(e) +;if(h(n))return;M("before:highlightElement",{el:e,language:n}),t=e +;const i=t.textContent,a=n?d(i,{language:n,ignoreIllegals:!0}):p(i) +;M("after:highlightElement",{el:e,result:a,text:i +}),e.innerHTML=a.value,((e,t,n)=>{const i=t?s[t]:n +;e.classList.add("hljs"),i&&e.classList.add(i)})(e,n,a.language),e.result={ +language:a.language,re:a.relevance,relavance:a.relevance +},a.second_best&&(e.second_best={language:a.second_best.language, +re:a.second_best.relevance,relavance:a.second_best.relevance})}const v=()=>{ +v.called||(v.called=!0, +K("10.6.0","initHighlighting() is deprecated. Use highlightAll() instead."), +document.querySelectorAll("pre code").forEach(x))};let w=!1;function y(){ +"loading"!==document.readyState?document.querySelectorAll("pre code").forEach(x):w=!0 +}function N(e){return e=(e||"").toLowerCase(),n[e]||n[s[e]]} +function R(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{ +s[e.toLowerCase()]=t}))}function k(e){const t=N(e) +;return t&&!t.disableAutodetect}function M(e,t){const n=e;a.forEach((e=>{ +e[n]&&e[n](t)}))} +"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{ +w&&y()}),!1),Object.assign(e,{highlight:d,highlightAuto:p,highlightAll:y, +fixMarkup:e=>{ +return K("10.2.0","fixMarkup will be removed entirely in v11.0"),K("10.2.0","Please see https://github.com/highlightjs/highlight.js/issues/2534"), +t=e, +u.tabReplace||u.useBR?t.replace(l,(e=>"\n"===e?u.useBR?"
":e:u.tabReplace?e.replace(/\t/g,u.tabReplace):e)):t +;var t},highlightElement:x, +highlightBlock:e=>(K("10.7.0","highlightBlock will be removed entirely in v12.0"), +K("10.7.0","Please use highlightElement now."),x(e)),configure:e=>{ +e.useBR&&(K("10.3.0","'useBR' will be removed entirely in v11.0"), +K("10.3.0","Please see https://github.com/highlightjs/highlight.js/issues/2559")), +u=V(u,e)},initHighlighting:v,initHighlightingOnLoad:()=>{ +K("10.6.0","initHighlightingOnLoad() is deprecated. Use highlightAll() instead."), +w=!0},registerLanguage:(t,i)=>{let s=null;try{s=i(e)}catch(e){ +if(U("Language definition for '{}' could not be registered.".replace("{}",t)), +!r)throw e;U(e),s=g} +s.name||(s.name=t),n[t]=s,s.rawDefinition=i.bind(null,e),s.aliases&&R(s.aliases,{ +languageName:t})},unregisterLanguage:e=>{delete n[e] +;for(const t of Object.keys(s))s[t]===e&&delete s[t]}, +listLanguages:()=>Object.keys(n),getLanguage:N,registerAliases:R, +requireLanguage:e=>{ +K("10.4.0","requireLanguage will be removed entirely in v11."), +K("10.4.0","Please see https://github.com/highlightjs/highlight.js/pull/2844") +;const t=N(e);if(t)return t +;throw Error("The '{}' language is required, but not loaded.".replace("{}",e))}, +autoDetection:k,inherit:V,addPlugin:e=>{(e=>{ +e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{ +e["before:highlightBlock"](Object.assign({block:t.el},t)) +}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{ +e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),a.push(e)}, +vuePlugin:P(e).VuePlugin}),e.debugMode=()=>{r=!1},e.safeMode=()=>{r=!0 +},e.versionString="10.7.2";for(const e in _)"object"==typeof _[e]&&t(_[e]) +;return Object.assign(e,_),e.addPlugin(m),e.addPlugin(D),e.addPlugin(E),e})({}) +}();"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs); +hljs.registerLanguage("apache",(()=>{"use strict";return e=>{const n={ +className:"number",begin:/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/} +;return{name:"Apache config",aliases:["apacheconf"],case_insensitive:!0, +contains:[e.HASH_COMMENT_MODE,{className:"section",begin:/<\/?/,end:/>/, +contains:[n,{className:"number",begin:/:\d{1,5}/ +},e.inherit(e.QUOTE_STRING_MODE,{relevance:0})]},{className:"attribute", +begin:/\w+/,relevance:0,keywords:{ +nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername" +},starts:{end:/$/,relevance:0,keywords:{literal:"on off all deny allow"}, +contains:[{className:"meta",begin:/\s\[/,end:/\]$/},{className:"variable", +begin:/[\$%]\{/,end:/\}/,contains:["self",{className:"number",begin:/[$%]\d+/}] +},n,{className:"number",begin:/\d+/},e.QUOTE_STRING_MODE]}}],illegal:/\S/}} +})()); +hljs.registerLanguage("bash",(()=>{"use strict";function e(...e){ +return e.map((e=>{return(s=e)?"string"==typeof s?s:s.source:null;var s +})).join("")}return s=>{const n={},t={begin:/\$\{/,end:/\}/,contains:["self",{ +begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{ +begin:e(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},t]});const a={ +className:"subst",begin:/\$\(/,end:/\)/,contains:[s.BACKSLASH_ESCAPE]},i={ +begin:/<<-?\s*(?=\w+)/,starts:{contains:[s.END_SAME_AS_BEGIN({begin:/(\w+)/, +end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/, +contains:[s.BACKSLASH_ESCAPE,n,a]};a.contains.push(c);const o={begin:/\$\(\(/, +end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},s.NUMBER_MODE,n] +},r=s.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10 +}),l={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0, +contains:[s.inherit(s.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{ +name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z._-]+\b/, +keyword:"if then else elif fi for while in do done case esac function", +literal:"true false", +built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp" +},contains:[r,s.SHEBANG(),l,o,s.HASH_COMMENT_MODE,i,c,{className:"",begin:/\\"/ +},{className:"string",begin:/'/,end:/'/},n]}}})()); +hljs.registerLanguage("c",(()=>{"use strict";function e(e){ +return((...e)=>e.map((e=>(e=>e?"string"==typeof e?e:e.source:null)(e))).join(""))("(",e,")?") +}return t=>{const n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}] +}),r="[a-zA-Z_]\\w*::",a="(decltype\\(auto\\)|"+e(r)+"[a-zA-Z_]\\w*"+e("<[^<>]+>")+")",i={ +className:"keyword",begin:"\\b[a-z\\d_]*_t\\b"},s={className:"string", +variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n", +contains:[t.BACKSLASH_ESCAPE]},{ +begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)", +end:"'",illegal:"."},t.END_SAME_AS_BEGIN({ +begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={ +className:"number",variants:[{begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)" +},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{ +"meta-keyword":"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include" +},contains:[{begin:/\\\n/,relevance:0},t.inherit(s,{className:"meta-string"}),{ +className:"meta-string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},l={ +className:"title",begin:e(r)+t.IDENT_RE,relevance:0 +},d=e(r)+t.IDENT_RE+"\\s*\\(",u={ +keyword:"int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid wchar_t short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignas alignof constexpr consteval constinit decltype concept co_await co_return co_yield requires noexcept static_assert thread_local restrict final override atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq", +built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary", +literal:"true false nullptr NULL"},m=[c,i,n,t.C_BLOCK_COMMENT_MODE,o,s],p={ +variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{ +beginKeywords:"new throw return else",end:/;/}],keywords:u,contains:m.concat([{ +begin:/\(/,end:/\)/,keywords:u,contains:m.concat(["self"]),relevance:0}]), +relevance:0},_={className:"function",begin:"("+a+"[\\*&\\s]+)+"+d, +returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/, +contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d, +returnBegin:!0,contains:[l],relevance:0},{className:"params",begin:/\(/, +end:/\)/,keywords:u,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,s,o,i,{ +begin:/\(/,end:/\)/,keywords:u,relevance:0, +contains:["self",n,t.C_BLOCK_COMMENT_MODE,s,o,i]}] +},i,n,t.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:u, +disableAutodetect:!0,illegal:"",keywords:u,contains:["self",i]},{begin:t.IDENT_RE+"::",keywords:u},{ +className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/, +contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{ +preprocessor:c,strings:s,keywords:u}}}})()); +hljs.registerLanguage("coffeescript",(()=>{"use strict" +;const e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],n=["true","false","null","undefined","NaN","Infinity"],a=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]) +;return r=>{const t={ +keyword:e.concat(["then","unless","until","loop","by","when","and","or","is","isnt","not"]).filter((i=["var","const","let","function","static"], +e=>!i.includes(e))),literal:n.concat(["yes","no","on","off"]), +built_in:a.concat(["npm","print"])};var i;const s="[A-Za-z$_][0-9A-Za-z$_]*",o={ +className:"subst",begin:/#\{/,end:/\}/,keywords:t +},c=[r.BINARY_NUMBER_MODE,r.inherit(r.C_NUMBER_MODE,{starts:{end:"(\\s*/)?", +relevance:0}}),{className:"string",variants:[{begin:/'''/,end:/'''/, +contains:[r.BACKSLASH_ESCAPE]},{begin:/'/,end:/'/,contains:[r.BACKSLASH_ESCAPE] +},{begin:/"""/,end:/"""/,contains:[r.BACKSLASH_ESCAPE,o]},{begin:/"/,end:/"/, +contains:[r.BACKSLASH_ESCAPE,o]}]},{className:"regexp",variants:[{begin:"///", +end:"///",contains:[o,r.HASH_COMMENT_MODE]},{begin:"//[gim]{0,3}(?=\\W)", +relevance:0},{begin:/\/(?![ *]).*?(?![\\]).\/[gim]{0,3}(?=\W)/}]},{begin:"@"+s +},{subLanguage:"javascript",excludeBegin:!0,excludeEnd:!0,variants:[{ +begin:"```",end:"```"},{begin:"`",end:"`"}]}];o.contains=c +;const l=r.inherit(r.TITLE_MODE,{begin:s}),d="(\\(.*\\)\\s*)?\\B[-=]>",g={ +className:"params",begin:"\\([^\\(]",returnBegin:!0,contains:[{begin:/\(/, +end:/\)/,keywords:t,contains:["self"].concat(c)}]};return{name:"CoffeeScript", +aliases:["coffee","cson","iced"],keywords:t,illegal:/\/\*/, +contains:c.concat([r.COMMENT("###","###"),r.HASH_COMMENT_MODE,{ +className:"function",begin:"^\\s*"+s+"\\s*=\\s*"+d,end:"[-=]>",returnBegin:!0, +contains:[l,g]},{begin:/[:\(,=]\s*/,relevance:0,contains:[{className:"function", +begin:d,end:"[-=]>",returnBegin:!0,contains:[g]}]},{className:"class", +beginKeywords:"class",end:"$",illegal:/[:="\[\]]/,contains:[{ +beginKeywords:"extends",endsWithParent:!0,illegal:/[:="\[\]]/,contains:[l]},l] +},{begin:s+":",end:":",returnBegin:!0,returnEnd:!0,relevance:0}])}}})()); +hljs.registerLanguage("cpp",(()=>{"use strict";function e(e){ +return t("(",e,")?")}function t(...e){return e.map((e=>{ +return(t=e)?"string"==typeof t?t:t.source:null;var t})).join("")}return n=>{ +const r=n.COMMENT("//","$",{contains:[{begin:/\\\n/}] +}),a="[a-zA-Z_]\\w*::",i="(decltype\\(auto\\)|"+e(a)+"[a-zA-Z_]\\w*"+e("<[^<>]+>")+")",s={ +className:"keyword",begin:"\\b[a-z\\d_]*_t\\b"},c={className:"string", +variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n", +contains:[n.BACKSLASH_ESCAPE]},{ +begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)", +end:"'",illegal:"."},n.END_SAME_AS_BEGIN({ +begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={ +className:"number",variants:[{begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)" +},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},l={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{ +"meta-keyword":"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include" +},contains:[{begin:/\\\n/,relevance:0},n.inherit(c,{className:"meta-string"}),{ +className:"meta-string",begin:/<.*?>/},r,n.C_BLOCK_COMMENT_MODE]},d={ +className:"title",begin:e(a)+n.IDENT_RE,relevance:0 +},u=e(a)+n.IDENT_RE+"\\s*\\(",m={ +keyword:"int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid wchar_t short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignas alignof constexpr consteval constinit decltype concept co_await co_return co_yield requires noexcept static_assert thread_local restrict final override atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq", +built_in:"_Bool _Complex _Imaginary", +_relevance_hints:["asin","atan2","atan","calloc","ceil","cosh","cos","exit","exp","fabs","floor","fmod","fprintf","fputs","free","frexp","auto_ptr","deque","list","queue","stack","vector","map","set","pair","bitset","multiset","multimap","unordered_set","fscanf","future","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","tolower","toupper","labs","ldexp","log10","log","malloc","realloc","memchr","memcmp","memcpy","memset","modf","pow","printf","putchar","puts","scanf","sinh","sin","snprintf","sprintf","sqrt","sscanf","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","tanh","tan","unordered_map","unordered_multiset","unordered_multimap","priority_queue","make_pair","array","shared_ptr","abort","terminate","abs","acos","vfprintf","vprintf","vsprintf","endl","initializer_list","unique_ptr","complex","imaginary","std","string","wstring","cin","cout","cerr","clog","stdin","stdout","stderr","stringstream","istringstream","ostringstream"], +literal:"true false nullptr NULL"},p={className:"function.dispatch",relevance:0, +keywords:m, +begin:t(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!while)/,n.IDENT_RE,(_=/\s*\(/, +t("(?=",_,")")))};var _;const g=[p,l,s,r,n.C_BLOCK_COMMENT_MODE,o,c],b={ +variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{ +beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:g.concat([{ +begin:/\(/,end:/\)/,keywords:m,contains:g.concat(["self"]),relevance:0}]), +relevance:0},f={className:"function",begin:"("+i+"[\\*&\\s]+)+"+u, +returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/, +contains:[{begin:"decltype\\(auto\\)",keywords:m,relevance:0},{begin:u, +returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/, +endsWithParent:!0,contains:[c,o]},{className:"params",begin:/\(/,end:/\)/, +keywords:m,relevance:0,contains:[r,n.C_BLOCK_COMMENT_MODE,c,o,s,{begin:/\(/, +end:/\)/,keywords:m,relevance:0,contains:["self",r,n.C_BLOCK_COMMENT_MODE,c,o,s] +}]},s,r,n.C_BLOCK_COMMENT_MODE,l]};return{name:"C++", +aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"",keywords:m,contains:["self",s]},{begin:n.IDENT_RE+"::",keywords:m},{ +className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/, +contains:[{beginKeywords:"final class struct"},n.TITLE_MODE]}]),exports:{ +preprocessor:l,strings:c,keywords:m}}}})()); +hljs.registerLanguage("csharp",(()=>{"use strict";return e=>{const n={ +keyword:["abstract","as","base","break","case","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","async","await","by","descending","equals","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","remove","select","set","unmanaged","value|0","var","when","where","with","yield"]), +built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"], +literal:["default","false","null","true"]},a=e.inherit(e.TITLE_MODE,{ +begin:"[a-zA-Z](\\.?\\w)*"}),i={className:"number",variants:[{ +begin:"\\b(0b[01']+)"},{ +begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{ +begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)" +}],relevance:0},s={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}] +},t=e.inherit(s,{illegal:/\n/}),r={className:"subst",begin:/\{/,end:/\}/, +keywords:n},l=e.inherit(r,{illegal:/\n/}),c={className:"string",begin:/\$"/, +end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/ +},e.BACKSLASH_ESCAPE,l]},o={className:"string",begin:/\$@"/,end:'"',contains:[{ +begin:/\{\{/},{begin:/\}\}/},{begin:'""'},r]},d=e.inherit(o,{illegal:/\n/, +contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},l]}) +;r.contains=[o,c,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,e.C_BLOCK_COMMENT_MODE], +l.contains=[d,c,t,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,e.inherit(e.C_BLOCK_COMMENT_MODE,{ +illegal:/\n/})];const g={variants:[o,c,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE] +},E={begin:"<",end:">",contains:[{beginKeywords:"in out"},a] +},_=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",b={ +begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"], +keywords:n,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0, +contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{ +begin:"\x3c!--|--\x3e"},{begin:""}]}] +}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#", +end:"$",keywords:{ +"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum" +}},g,i,{beginKeywords:"class interface",relevance:0,end:/[{;=]/, +illegal:/[^\s:,]/,contains:[{beginKeywords:"where class" +},a,E,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace", +relevance:0,end:/[{;=]/,illegal:/[^\s:]/, +contains:[a,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ +beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/, +contains:[a,E,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta", +begin:"^\\s*\\[",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{ +className:"meta-string",begin:/"/,end:/"/}]},{ +beginKeywords:"new return throw await else",relevance:0},{className:"function", +begin:"("+_+"\\s+)+"+e.IDENT_RE+"\\s*(<.+>\\s*)?\\(",returnBegin:!0, +end:/\s*[{;=]/,excludeEnd:!0,keywords:n,contains:[{ +beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial", +relevance:0},{begin:e.IDENT_RE+"\\s*(<.+>\\s*)?\\(",returnBegin:!0, +contains:[e.TITLE_MODE,E],relevance:0},{className:"params",begin:/\(/,end:/\)/, +excludeBegin:!0,excludeEnd:!0,keywords:n,relevance:0, +contains:[g,i,e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},b]}}})()); +hljs.registerLanguage("css",(()=>{"use strict" +;const e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],t=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],i=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],r=["align-content","align-items","align-self","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","auto","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","clip-path","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-variant","font-variant-ligatures","font-variation-settings","font-weight","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inherit","initial","justify-content","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","mask","max-height","max-width","min-height","min-width","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","pointer-events","position","quotes","resize","right","src","tab-size","table-layout","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","white-space","widows","width","word-break","word-spacing","word-wrap","z-index"].reverse() +;return n=>{const a=(e=>({IMPORTANT:{className:"meta",begin:"!important"}, +HEXCOLOR:{className:"number",begin:"#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"}, +ATTRIBUTE_SELECTOR_MODE:{className:"selector-attr",begin:/\[/,end:/\]/, +illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]} +}))(n),l=[n.APOS_STRING_MODE,n.QUOTE_STRING_MODE];return{name:"CSS", +case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"}, +classNameAliases:{keyframePosition:"selector-tag"}, +contains:[n.C_BLOCK_COMMENT_MODE,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/ +},n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0 +},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0 +},a.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{ +begin:":("+i.join("|")+")"},{begin:"::("+o.join("|")+")"}]},{ +className:"attribute",begin:"\\b("+r.join("|")+")\\b"},{begin:":",end:"[;}]", +contains:[a.HEXCOLOR,a.IMPORTANT,n.CSS_NUMBER_MODE,...l,{ +begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri" +},contains:[{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}] +},{className:"built_in",begin:/[\w-]+(?=\()/}]},{ +begin:(s=/@/,((...e)=>e.map((e=>(e=>e?"string"==typeof e?e:e.source:null)(e))).join(""))("(?=",s,")")), +end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword", +begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0, +relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only", +attribute:t.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute" +},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag", +begin:"\\b("+e.join("|")+")\\b"}]};var s}})()); +hljs.registerLanguage("diff",(()=>{"use strict";return e=>({name:"Diff", +aliases:["patch"],contains:[{className:"meta",relevance:10,variants:[{ +begin:/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/},{begin:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{ +begin:/^--- +\d+,\d+ +----$/}]},{className:"comment",variants:[{begin:/Index: /, +end:/$/},{begin:/^index/,end:/$/},{begin:/={3,}/,end:/$/},{begin:/^-{3}/,end:/$/ +},{begin:/^\*{3} /,end:/$/},{begin:/^\+{3}/,end:/$/},{begin:/^\*{15}$/},{ +begin:/^diff --git/,end:/$/}]},{className:"addition",begin:/^\+/,end:/$/},{ +className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/, +end:/$/}]})})()); +hljs.registerLanguage("go",(()=>{"use strict";return e=>{const n={ +keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune", +literal:"true false iota nil", +built_in:"append cap close complex copy imag len make new panic print println real recover delete" +};return{name:"Go",aliases:["golang"],keywords:n,illegal:"{"use strict";function e(...e){ +return e.map((e=>{return(n=e)?"string"==typeof n?n:n.source:null;var n +})).join("")}return n=>{const a="HTTP/(2|1\\.[01])",s={className:"attribute", +begin:e("^",/[A-Za-z][A-Za-z0-9-]*/,"(?=\\:\\s)"),starts:{contains:[{ +className:"punctuation",begin:/: /,relevance:0,starts:{end:"$",relevance:0}}]} +},t=[s,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0}}];return{ +name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{begin:"^(?="+a+" \\d{3})", +end:/$/,contains:[{className:"meta",begin:a},{className:"number", +begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/,contains:t}},{ +begin:"(?=^[A-Z]+ (.*?) "+a+"$)",end:/$/,contains:[{className:"string", +begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{className:"meta",begin:a},{ +className:"keyword",begin:"[A-Z]+"}],starts:{end:/\b\B/,illegal:/\S/,contains:t} +},n.inherit(s,{relevance:0})]}}})()); +hljs.registerLanguage("ini",(()=>{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function n(...n){ +return n.map((n=>e(n))).join("")}return s=>{const a={className:"number", +relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:s.NUMBER_RE}] +},i=s.COMMENT();i.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const t={ +className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/ +}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={ +className:"string",contains:[s.BACKSLASH_ESCAPE],variants:[{begin:"'''", +end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"' +},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[i,r,t,l,a,"self"], +relevance:0 +},g="("+[/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/].map((n=>e(n))).join("|")+")" +;return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/, +contains:[i,{className:"section",begin:/\[+/,end:/\]+/},{ +begin:n(g,"(\\s*\\.\\s*",g,")*",n("(?=",/\s*=\s*[^#\s]/,")")),className:"attr", +starts:{end:/$/,contains:[i,c,r,t,l,a]}}]}}})()); +hljs.registerLanguage("java",(()=>{"use strict" +;var e="\\.([0-9](_*[0-9])*)",n="[0-9a-fA-F](_*[0-9a-fA-F])*",a={ +className:"number",variants:[{ +begin:`(\\b([0-9](_*[0-9])*)((${e})|\\.)?|(${e}))[eE][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:`\\b([0-9](_*[0-9])*)((${e})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{ +begin:`(${e})[fFdD]?\\b`},{begin:"\\b([0-9](_*[0-9])*)[fFdD]\\b"},{ +begin:`\\b0[xX]((${n})\\.?|(${n})?\\.(${n}))[pP][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${n})[lL]?\\b`},{ +begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}], +relevance:0};return e=>{ +var n="false synchronized int abstract float private char boolean var static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",s={ +className:"meta",begin:"@[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*", +contains:[{begin:/\(/,end:/\)/,contains:["self"]}]};const r=a;return{ +name:"Java",aliases:["jsp"],keywords:n,illegal:/<\/|#/, +contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/, +relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{ +begin:/import java\.[a-z]+\./,keywords:"import",relevance:2 +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{ +className:"class",beginKeywords:"class interface enum",end:/[{;=]/, +excludeEnd:!0,relevance:1,keywords:"class interface enum",illegal:/[:"\[\]]/, +contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{ +beginKeywords:"new throw return else",relevance:0},{className:"class", +begin:"record\\s+"+e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,excludeEnd:!0, +end:/[{;=]/,keywords:n,contains:[{beginKeywords:"record"},{ +begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0, +contains:[e.UNDERSCORE_TITLE_MODE]},{className:"params",begin:/\(/,end:/\)/, +keywords:n,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"function", +begin:"([\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*(<[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*(\\s*,\\s*[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*)*>)?\\s+)+"+e.UNDERSCORE_IDENT_RE+"\\s*\\(", +returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:n,contains:[{ +begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0, +contains:[e.UNDERSCORE_TITLE_MODE]},{className:"params",begin:/\(/,end:/\)/, +keywords:n,relevance:0, +contains:[s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE] +},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},r,s]}}})()); +hljs.registerLanguage("javascript",(()=>{"use strict" +;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]) +;function r(e){return t("(?=",e,")")}function t(...e){return e.map((e=>{ +return(n=e)?"string"==typeof n?n:n.source:null;var n})).join("")}return i=>{ +const c=e,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/, +isTrulyOpeningTag:(e,n)=>{const a=e[0].length+e.index,s=e.input[a] +;"<"!==s?">"===s&&(((e,{after:n})=>{const a="", +returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{ +begin:i.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0 +},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:f}]}] +},{begin:/,/,relevance:0},{className:"",begin:/\s/,end:/\s*/,skip:!0},{ +variants:[{begin:"<>",end:""},{begin:o.begin,"on:begin":o.isTrulyOpeningTag, +end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0, +contains:["self"]}]}],relevance:0},{className:"function", +beginKeywords:"function",end:/[{;]/,excludeEnd:!0,keywords:l, +contains:["self",i.inherit(i.TITLE_MODE,{begin:c}),p],illegal:/%/},{ +beginKeywords:"while if switch catch for"},{className:"function", +begin:i.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{", +returnBegin:!0,contains:[p,i.inherit(i.TITLE_MODE,{begin:c})]},{variants:[{ +begin:"\\."+c},{begin:"\\$"+c}],relevance:0},{className:"class", +beginKeywords:"class",end:/[{;=]/,excludeEnd:!0,illegal:/[:"[\]]/,contains:[{ +beginKeywords:"extends"},i.UNDERSCORE_TITLE_MODE]},{begin:/\b(?=constructor)/, +end:/[{;]/,excludeEnd:!0,contains:[i.inherit(i.TITLE_MODE,{begin:c}),"self",p] +},{begin:"(get|set)\\s+(?="+c+"\\()",end:/\{/,keywords:"get set", +contains:[i.inherit(i.TITLE_MODE,{begin:c}),{begin:/\(\)/},p]},{begin:/\$[(.]/}] +}}})()); +hljs.registerLanguage("json",(()=>{"use strict";return n=>{const e={ +literal:"true false null" +},i=[n.C_LINE_COMMENT_MODE,n.C_BLOCK_COMMENT_MODE],a=[n.QUOTE_STRING_MODE,n.C_NUMBER_MODE],l={ +end:",",endsWithParent:!0,excludeEnd:!0,contains:a,keywords:e},t={begin:/\{/, +end:/\}/,contains:[{className:"attr",begin:/"/,end:/"/, +contains:[n.BACKSLASH_ESCAPE],illegal:"\\n"},n.inherit(l,{begin:/:/ +})].concat(i),illegal:"\\S"},s={begin:"\\[",end:"\\]",contains:[n.inherit(l)], +illegal:"\\S"};return a.push(t,s),i.forEach((n=>{a.push(n)})),{name:"JSON", +contains:a,keywords:e,illegal:"\\S"}}})()); +hljs.registerLanguage("kotlin",(()=>{"use strict" +;var e="\\.([0-9](_*[0-9])*)",n="[0-9a-fA-F](_*[0-9a-fA-F])*",a={ +className:"number",variants:[{ +begin:`(\\b([0-9](_*[0-9])*)((${e})|\\.)?|(${e}))[eE][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:`\\b([0-9](_*[0-9])*)((${e})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{ +begin:`(${e})[fFdD]?\\b`},{begin:"\\b([0-9](_*[0-9])*)[fFdD]\\b"},{ +begin:`\\b0[xX]((${n})\\.?|(${n})?\\.(${n}))[pP][+-]?([0-9](_*[0-9])*)[fFdD]?\\b` +},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${n})[lL]?\\b`},{ +begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}], +relevance:0};return e=>{const n={ +keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual", +built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing", +literal:"true false null"},i={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@" +},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},t={ +className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},r={className:"string", +variants:[{begin:'"""',end:'"""(?=[^"])',contains:[t,s]},{begin:"'",end:"'", +illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/, +contains:[e.BACKSLASH_ESCAPE,t,s]}]};s.contains.push(r);const l={ +className:"meta", +begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?" +},c={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/, +end:/\)/,contains:[e.inherit(r,{className:"meta-string"})]}] +},o=a,b=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),E={ +variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/, +contains:[]}]},d=E;return d.variants[1].contains=[E],E.variants[1].contains=[d], +{name:"Kotlin",aliases:["kt","kts"],keywords:n, +contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag", +begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,b,{className:"keyword", +begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol", +begin:/@\w+/}]}},i,l,c,{className:"function",beginKeywords:"fun",end:"[(]|$", +returnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{ +begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0, +contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin://, +keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/, +endsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\/]/, +endsWithParent:!0,contains:[E,e.C_LINE_COMMENT_MODE,b],relevance:0 +},e.C_LINE_COMMENT_MODE,b,l,c,r,e.C_NUMBER_MODE]},b]},{className:"class", +beginKeywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0, +illegal:"extends implements",contains:[{ +beginKeywords:"public protected internal private constructor" +},e.UNDERSCORE_TITLE_MODE,{className:"type",begin://,excludeBegin:!0, +excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,]|$/, +excludeBegin:!0,returnEnd:!0},l,c]},r,{className:"meta",begin:"^#!/usr/bin/env", +end:"$",illegal:"\n"},o]}}})()); +hljs.registerLanguage("less",(()=>{"use strict" +;const e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],t=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],i=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],n=["align-content","align-items","align-self","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","auto","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","clip-path","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-variant","font-variant-ligatures","font-variation-settings","font-weight","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inherit","initial","justify-content","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","mask","max-height","max-width","min-height","min-width","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","pointer-events","position","quotes","resize","right","src","tab-size","table-layout","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","white-space","widows","width","word-break","word-spacing","word-wrap","z-index"].reverse(),r=i.concat(o) +;return a=>{const s=(e=>({IMPORTANT:{className:"meta",begin:"!important"}, +HEXCOLOR:{className:"number",begin:"#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"}, +ATTRIBUTE_SELECTOR_MODE:{className:"selector-attr",begin:/\[/,end:/\]/, +illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]} +}))(a),l=r,d="([\\w-]+|@\\{[\\w-]+\\})",c=[],g=[],b=e=>({className:"string", +begin:"~?"+e+".*?"+e}),m=(e,t,i)=>({className:e,begin:t,relevance:i}),u={ +$pattern:/[a-z-]+/,keyword:"and or not only",attribute:t.join(" ")},p={ +begin:"\\(",end:"\\)",contains:g,keywords:u,relevance:0} +;g.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,b("'"),b('"'),a.CSS_NUMBER_MODE,{ +begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]", +excludeEnd:!0} +},s.HEXCOLOR,p,m("variable","@@?[\\w-]+",10),m("variable","@\\{[\\w-]+\\}"),m("built_in","~?`[^`]*?`"),{ +className:"attribute",begin:"[\\w-]+\\s*:",end:":",returnBegin:!0,excludeEnd:!0 +},s.IMPORTANT);const f=g.concat({begin:/\{/,end:/\}/,contains:c}),h={ +beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not" +}].concat(g)},w={begin:d+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0, +contains:[{begin:/-(webkit|moz|ms|o)-/},{className:"attribute", +begin:"\\b("+n.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0, +illegal:"[<=$]",relevance:0,contains:g}}]},v={className:"keyword", +begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b", +starts:{end:"[;{}]",keywords:u,returnEnd:!0,contains:g,relevance:0}},y={ +className:"variable",variants:[{begin:"@[\\w-]+\\s*:",relevance:15},{ +begin:"@[\\w-]+"}],starts:{end:"[;}]",returnEnd:!0,contains:f}},k={variants:[{ +begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:d,end:/\{/}],returnBegin:!0, +returnEnd:!0,illegal:"[<='$\"]",relevance:0, +contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,h,m("keyword","all\\b"),m("variable","@\\{[\\w-]+\\}"),{ +begin:"\\b("+e.join("|")+")\\b",className:"selector-tag" +},m("selector-tag",d+"%?",0),m("selector-id","#"+d),m("selector-class","\\."+d,0),m("selector-tag","&",0),s.ATTRIBUTE_SELECTOR_MODE,{ +className:"selector-pseudo",begin:":("+i.join("|")+")"},{ +className:"selector-pseudo",begin:"::("+o.join("|")+")"},{begin:"\\(",end:"\\)", +contains:f},{begin:"!important"}]},E={begin:`[\\w-]+:(:)?(${l.join("|")})`, +returnBegin:!0,contains:[k]} +;return c.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,v,y,E,w,k),{ +name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:c}}})()); +hljs.registerLanguage("lua",(()=>{"use strict";return e=>{ +const t="\\[=*\\[",a="\\]=*\\]",n={begin:t,end:a,contains:["self"] +},o=[e.COMMENT("--(?!\\[=*\\[)","$"),e.COMMENT("--\\[=*\\[",a,{contains:[n], +relevance:10})];return{name:"Lua",keywords:{$pattern:e.UNDERSCORE_IDENT_RE, +literal:"true false nil", +keyword:"and break do else elseif end for goto if in local not or repeat return then until while", +built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove" +},contains:o.concat([{className:"function",beginKeywords:"function",end:"\\)", +contains:[e.inherit(e.TITLE_MODE,{ +begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params", +begin:"\\(",endsWithParent:!0,contains:o}].concat(o) +},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string", +begin:t,end:a,contains:[n],relevance:5}])}}})()); +hljs.registerLanguage("makefile",(()=>{"use strict";return e=>{const i={ +className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)", +contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function n(e){return a("(?=",e,")")} +function a(...n){return n.map((n=>e(n))).join("")}function s(...n){ +return"("+n.map((n=>e(n))).join("|")+")"}return e=>{ +const t=a(/[A-Z_]/,a("(",/[A-Z0-9_.-]*:/,")?"),/[A-Z0-9_.-]*/),i={ +className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},r={begin:/\s/, +contains:[{className:"meta-keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}] +},c=e.inherit(r,{begin:/\(/,end:/\)/}),l=e.inherit(e.APOS_STRING_MODE,{ +className:"meta-string"}),g=e.inherit(e.QUOTE_STRING_MODE,{ +className:"meta-string"}),m={endsWithParent:!0,illegal:/`]+/}]}] +}]};return{name:"HTML, XML", +aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"], +case_insensitive:!0,contains:[{className:"meta",begin://, +relevance:10,contains:[r,g,l,c,{begin:/\[/,end:/\]/,contains:[{className:"meta", +begin://,contains:[r,c,g,l]}]}]},e.COMMENT(//,{ +relevance:10}),{begin://,relevance:10},i,{ +className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag", +begin:/)/,end:/>/,keywords:{name:"style"},contains:[m],starts:{ +end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag", +begin:/)/,end:/>/,keywords:{name:"script"},contains:[m],starts:{ +end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{ +className:"tag",begin:/<>|<\/>/},{className:"tag", +begin:a(//,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name", +begin:t,relevance:0,starts:m}]},{className:"tag",begin:a(/<\//,n(a(t,/>/))), +contains:[{className:"name",begin:t,relevance:0},{begin:/>/,relevance:0, +endsParent:!0}]}]}}})()); +hljs.registerLanguage("markdown",(()=>{"use strict";function n(...n){ +return n.map((n=>{return(e=n)?"string"==typeof e?e:e.source:null;var e +})).join("")}return e=>{const a={begin:/<\/?[A-Za-z_]/,end:">", +subLanguage:"xml",relevance:0},i={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0 +},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/, +relevance:2},{begin:n(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/), +relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{ +begin:/\[.+?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{ +className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0, +returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)", +excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[", +end:"\\]",excludeBegin:!0,excludeEnd:!0}]},s={className:"strong",contains:[], +variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},c={ +className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{ +begin:/_(?!_)/,end:/_/,relevance:0}]};s.contains.push(c),c.contains.push(s) +;let t=[a,i] +;return s.contains=s.contains.concat(t),c.contains=c.contains.concat(t), +t=t.concat(s,c),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{ +className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:t},{ +begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n", +contains:t}]}]},a,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)", +end:"\\s+",excludeEnd:!0},s,c,{className:"quote",begin:"^>\\s+",contains:t, +end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{ +begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{ +begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))", +contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{ +begin:"^[-\\*]{3,}",end:"$"},i,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{ +className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{ +className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}})()); +hljs.registerLanguage("nginx",(()=>{"use strict";return e=>{const n={ +className:"variable",variants:[{begin:/\$\d+/},{begin:/\$\{/,end:/\}/},{ +begin:/[$@]/+e.UNDERSCORE_IDENT_RE}]},a={endsWithParent:!0,keywords:{ +$pattern:"[a-z/_]+", +literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll" +},relevance:0,illegal:"=>",contains:[e.HASH_COMMENT_MODE,{className:"string", +contains:[e.BACKSLASH_ESCAPE,n],variants:[{begin:/"/,end:/"/},{begin:/'/,end:/'/ +}]},{begin:"([a-z]+):/",end:"\\s",endsWithParent:!0,excludeEnd:!0,contains:[n] +},{className:"regexp",contains:[e.BACKSLASH_ESCAPE,n],variants:[{begin:"\\s\\^", +end:"\\s|\\{|;",returnEnd:!0},{begin:"~\\*?\\s+",end:"\\s|\\{|;",returnEnd:!0},{ +begin:"\\*(\\.[a-z\\-]+)+"},{begin:"([a-z\\-]+\\.)+\\*"}]},{className:"number", +begin:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{ +className:"number",begin:"\\b\\d+[kKmMgGdshdwy]*\\b",relevance:0},n]};return{ +name:"Nginx config",aliases:["nginxconf"],contains:[e.HASH_COMMENT_MODE,{ +begin:e.UNDERSCORE_IDENT_RE+"\\s+\\{",returnBegin:!0,end:/\{/,contains:[{ +className:"section",begin:e.UNDERSCORE_IDENT_RE}],relevance:0},{ +begin:e.UNDERSCORE_IDENT_RE+"\\s",end:";|\\{",returnBegin:!0,contains:[{ +className:"attribute",begin:e.UNDERSCORE_IDENT_RE,starts:a}],relevance:0}], +illegal:"[^\\s\\}]"}}})()); +hljs.registerLanguage("objectivec",(()=>{"use strict";return e=>{ +const n=/[a-zA-Z@][a-zA-Z0-9_]*/,_={$pattern:n, +keyword:"@interface @class @protocol @implementation"};return{ +name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"], +keywords:{$pattern:n, +keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN", +literal:"false true FALSE TRUE nil YES NO NULL", +built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once" +},illegal:"/,end:/$/, +illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{ +className:"class",begin:"("+_.keyword.split(" ").join("|")+")\\b",end:/(\{|$)/, +excludeEnd:!0,keywords:_,contains:[e.UNDERSCORE_TITLE_MODE]},{ +begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}})()); +hljs.registerLanguage("perl",(()=>{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function n(...n){ +return n.map((n=>e(n))).join("")}function t(...n){ +return"("+n.map((n=>e(n))).join("|")+")"}return e=>{ +const r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/, +keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0" +},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},a={begin:/->\{/, +end:/\}/},o={variants:[{begin:/\$\d/},{ +begin:n(/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])") +},{begin:/[$%@][^\s\w{]/,relevance:0}] +},c=[e.BACKSLASH_ESCAPE,i,o],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],l=(e,t,s="\\1")=>{ +const i="\\1"===s?s:n(s,t) +;return n(n("(?:",e,")"),t,/(?:\\.|[^\\\/])*?/,i,/(?:\\.|[^\\\/])*?/,s,r) +},d=(e,t,s)=>n(n("(?:",e,")"),t,/(?:\\.|[^\\\/])*?/,s,r),p=[o,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{ +endsWithParent:!0}),a,{className:"string",contains:c,variants:[{ +begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[", +end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{ +begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">", +relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'", +contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`", +contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{ +begin:"-?\\w+\\s*=>",relevance:0}]},{className:"number", +begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b", +relevance:0},{ +begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*", +keywords:"split return print reverse grep",relevance:0, +contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{ +begin:l("s|tr|y",t(...g))},{begin:l("s|tr|y","\\(","\\)")},{ +begin:l("s|tr|y","\\[","\\]")},{begin:l("s|tr|y","\\{","\\}")}],relevance:2},{ +className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{ +begin:d("(?:m|qr)?",/\//,/\//)},{begin:d("m|qr",t(...g),/\1/)},{ +begin:d("m|qr",/\(/,/\)/)},{begin:d("m|qr",/\[/,/\]/)},{ +begin:d("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub", +end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{ +begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$", +subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}] +}];return i.contains=p,a.contains=p,{name:"Perl",aliases:["pl","pm"],keywords:s, +contains:p}}})()); +hljs.registerLanguage("php",(()=>{"use strict";return e=>{const r={ +className:"variable", +begin:"\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?![A-Za-z0-9])(?![$])"},t={ +className:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?[=]?/},{ +begin:/\?>/}]},a={className:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/, +end:/\}/}]},n=e.inherit(e.APOS_STRING_MODE,{illegal:null +}),i=e.inherit(e.QUOTE_STRING_MODE,{illegal:null, +contains:e.QUOTE_STRING_MODE.contains.concat(a)}),o=e.END_SAME_AS_BEGIN({ +begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/, +contains:e.QUOTE_STRING_MODE.contains.concat(a)}),l={className:"string", +contains:[e.BACKSLASH_ESCAPE,t],variants:[e.inherit(n,{begin:"b'",end:"'" +}),e.inherit(i,{begin:'b"',end:'"'}),i,n,o]},s={className:"number",variants:[{ +begin:"\\b0b[01]+(?:_[01]+)*\\b"},{begin:"\\b0o[0-7]+(?:_[0-7]+)*\\b"},{ +begin:"\\b0x[\\da-f]+(?:_[\\da-f]+)*\\b"},{ +begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:e[+-]?\\d+)?" +}],relevance:0},c={ +keyword:"__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ die echo exit include include_once print require require_once array abstract and as binary bool boolean break callable case catch class clone const continue declare default do double else elseif empty enddeclare endfor endforeach endif endswitch endwhile enum eval extends final finally float for foreach from global goto if implements instanceof insteadof int integer interface isset iterable list match|0 mixed new object or private protected public real return string switch throw trait try unset use var void while xor yield", +literal:"false null true", +built_in:"Error|0 AppendIterator ArgumentCountError ArithmeticError ArrayIterator ArrayObject AssertionError BadFunctionCallException BadMethodCallException CachingIterator CallbackFilterIterator CompileError Countable DirectoryIterator DivisionByZeroError DomainException EmptyIterator ErrorException Exception FilesystemIterator FilterIterator GlobIterator InfiniteIterator InvalidArgumentException IteratorIterator LengthException LimitIterator LogicException MultipleIterator NoRewindIterator OutOfBoundsException OutOfRangeException OuterIterator OverflowException ParentIterator ParseError RangeException RecursiveArrayIterator RecursiveCachingIterator RecursiveCallbackFilterIterator RecursiveDirectoryIterator RecursiveFilterIterator RecursiveIterator RecursiveIteratorIterator RecursiveRegexIterator RecursiveTreeIterator RegexIterator RuntimeException SeekableIterator SplDoublyLinkedList SplFileInfo SplFileObject SplFixedArray SplHeap SplMaxHeap SplMinHeap SplObjectStorage SplObserver SplObserver SplPriorityQueue SplQueue SplStack SplSubject SplSubject SplTempFileObject TypeError UnderflowException UnexpectedValueException UnhandledMatchError ArrayAccess Closure Generator Iterator IteratorAggregate Serializable Stringable Throwable Traversable WeakReference WeakMap Directory __PHP_Incomplete_Class parent php_user_filter self static stdClass" +};return{aliases:["php3","php4","php5","php6","php7","php8"], +case_insensitive:!0,keywords:c, +contains:[e.HASH_COMMENT_MODE,e.COMMENT("//","$",{contains:[t] +}),e.COMMENT("/\\*","\\*/",{contains:[{className:"doctag",begin:"@[A-Za-z]+"}] +}),e.COMMENT("__halt_compiler.+?;",!1,{endsWithParent:!0, +keywords:"__halt_compiler"}),t,{className:"keyword",begin:/\$this\b/},r,{ +begin:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{className:"function", +relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0, +illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{ +begin:"=>",endsParent:!0},{className:"params",begin:"\\(",end:"\\)", +excludeBegin:!0,excludeEnd:!0,keywords:c, +contains:["self",r,e.C_BLOCK_COMMENT_MODE,l,s]}]},{className:"class",variants:[{ +beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait", +illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{ +beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{ +beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/, +contains:[e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"use",relevance:0,end:";", +contains:[e.UNDERSCORE_TITLE_MODE]},l,s]}}})()); +hljs.registerLanguage("php-template",(()=>{"use strict";return n=>({ +name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/, +subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"', +end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},n.inherit(n.APOS_STRING_MODE,{ +illegal:null,className:null,contains:null,skip:!0 +}),n.inherit(n.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null, +skip:!0})]}]})})()); +hljs.registerLanguage("plaintext",(()=>{"use strict";return t=>({ +name:"Plain text",aliases:["text","txt"],disableAutodetect:!0})})()); +hljs.registerLanguage("properties",(()=>{"use strict";return e=>{ +var n="[ \\t\\f]*",a=n+"[:=]"+n,t="("+a+"|[ \\t\\f]+)",r="([^\\\\\\W:= \\t\\f\\n]|\\\\.)+",s="([^\\\\:= \\t\\f\\n]|\\\\.)+",i={ +end:t,relevance:0,starts:{className:"string",end:/$/,relevance:0,contains:[{ +begin:"\\\\\\\\"},{begin:"\\\\\\n"}]}};return{name:".properties", +case_insensitive:!0,illegal:/\S/,contains:[e.COMMENT("^\\s*[!#]","$"),{ +returnBegin:!0,variants:[{begin:r+a,relevance:1},{begin:r+"[ \\t\\f]+", +relevance:0}],contains:[{className:"attr",begin:r,endsParent:!0,relevance:0}], +starts:i},{begin:s+t,returnBegin:!0,relevance:0,contains:[{className:"meta", +begin:s,endsParent:!0,relevance:0}],starts:i},{className:"attr",relevance:0, +begin:s+n+"$"}]}}})()); +hljs.registerLanguage("python",(()=>{"use strict";return e=>{const n={ +$pattern:/[A-Za-z]\w+|__\w+__/, +keyword:["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"], +built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"], +literal:["__debug__","Ellipsis","False","None","NotImplemented","True"], +type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"] +},a={className:"meta",begin:/^(>>>|\.\.\.) /},i={className:"subst",begin:/\{/, +end:/\}/,keywords:n,illegal:/#/},s={begin:/\{\{/,relevance:0},t={ +className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{ +begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/, +contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{ +begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/, +contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{ +begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/, +contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/, +end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,i]},{begin:/([uU]|[rR])'/,end:/'/, +relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{ +begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/, +end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/, +contains:[e.BACKSLASH_ESCAPE,s,i]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/, +contains:[e.BACKSLASH_ESCAPE,s,i]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE] +},r="[0-9](_?[0-9])*",l=`(\\b(${r}))?\\.(${r})|\\b(${r})\\.`,b={ +className:"number",relevance:0,variants:[{ +begin:`(\\b(${r})|(${l}))[eE][+-]?(${r})[jJ]?\\b`},{begin:`(${l})[jJ]?`},{ +begin:"\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?\\b"},{ +begin:"\\b0[bB](_?[01])+[lL]?\\b"},{begin:"\\b0[oO](_?[0-7])+[lL]?\\b"},{ +begin:"\\b0[xX](_?[0-9a-fA-F])+[lL]?\\b"},{begin:`\\b(${r})[jJ]\\b`}]},o={ +className:"comment", +begin:(d=/# type:/,((...e)=>e.map((e=>(e=>e?"string"==typeof e?e:e.source:null)(e))).join(""))("(?=",d,")")), +end:/$/,keywords:n,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/, +endsWithParent:!0}]},c={className:"params",variants:[{className:"", +begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0, +keywords:n,contains:["self",a,b,t,e.HASH_COMMENT_MODE]}]};var d +;return i.contains=[t,b,a],{name:"Python",aliases:["py","gyp","ipython"], +keywords:n,illegal:/(<\/|->|\?)|=>/,contains:[a,b,{begin:/\bself\b/},{ +beginKeywords:"if",relevance:0},t,o,e.HASH_COMMENT_MODE,{variants:[{ +className:"function",beginKeywords:"def"},{className:"class", +beginKeywords:"class"}],end:/:/,illegal:/[${=;\n,]/, +contains:[e.UNDERSCORE_TITLE_MODE,c,{begin:/->/,endsWithParent:!0,keywords:n}] +},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,c,t]}]}}})()); +hljs.registerLanguage("python-repl",(()=>{"use strict";return s=>({ +aliases:["pycon"],contains:[{className:"meta",starts:{end:/ |$/,starts:{end:"$", +subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{ +begin:/^\.\.\.(?=[ ]|$)/}]}]})})()); +hljs.registerLanguage("r",(()=>{"use strict";function e(...e){return e.map((e=>{ +return(a=e)?"string"==typeof a?a:a.source:null;var a})).join("")}return a=>{ +const n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/;return{name:"R", +illegal:/->/,keywords:{$pattern:n, +keyword:"function if in break next repeat else for while", +literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10", +built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm" +},compilerExtensions:[(a,n)=>{if(!a.beforeMatch)return +;if(a.starts)throw Error("beforeMatch cannot be used with starts") +;const i=Object.assign({},a);Object.keys(a).forEach((e=>{delete a[e] +})),a.begin=e(i.beforeMatch,e("(?=",i.begin,")")),a.starts={relevance:0, +contains:[Object.assign(i,{endsParent:!0})]},a.relevance=0,delete i.beforeMatch +}],contains:[a.COMMENT(/#'/,/$/,{contains:[{className:"doctag", +begin:"@examples",starts:{contains:[{begin:/\n/},{begin:/#'\s*(?=@[a-zA-Z]+)/, +endsParent:!0},{begin:/#'/,end:/$/,excludeBegin:!0}]}},{className:"doctag", +begin:"@param",end:/$/,contains:[{className:"variable",variants:[{begin:n},{ +begin:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{className:"doctag", +begin:/@[a-zA-Z]+/},{className:"meta-keyword",begin:/\\[a-zA-Z]+/}] +}),a.HASH_COMMENT_MODE,{className:"string",contains:[a.BACKSLASH_ESCAPE], +variants:[a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/ +}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/ +}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/ +}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/ +}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/ +}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"', +relevance:0},{begin:"'",end:"'",relevance:0}]},{className:"number",relevance:0, +beforeMatch:/([^a-zA-Z0-9._])/,variants:[{ +match:/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/},{ +match:/0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/},{ +match:/(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/}]},{begin:"%",end:"%"},{ +begin:e(/[a-zA-Z][a-zA-Z_0-9]*/,"\\s+<-\\s+")},{begin:"`",end:"`",contains:[{ +begin:/\\./}]}]}}})()); +hljs.registerLanguage("ruby",(()=>{"use strict";function e(...e){ +return e.map((e=>{return(n=e)?"string"==typeof n?n:n.source:null;var n +})).join("")}return n=>{ +const a="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i={ +keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor __FILE__", +built_in:"proc lambda",literal:"true false nil"},s={className:"doctag", +begin:"@[A-Za-z]+"},r={begin:"#<",end:">"},b=[n.COMMENT("#","$",{contains:[s] +}),n.COMMENT("^=begin","^=end",{contains:[s],relevance:10 +}),n.COMMENT("^__END__","\\n$")],c={className:"subst",begin:/#\{/,end:/\}/, +keywords:i},t={className:"string",contains:[n.BACKSLASH_ESCAPE,c],variants:[{ +begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/, +end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{ +begin:/%[qQwWx]?/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/, +end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{ +begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{ +begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{ +begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{ +begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{ +begin:/<<[-~]?'?(\w+)\n(?:[^\n]*\n)*?\s*\1\b/,returnBegin:!0,contains:[{ +begin:/<<[-~]?'?/},n.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/, +contains:[n.BACKSLASH_ESCAPE,c]})]}]},g="[0-9](_?[0-9])*",d={className:"number", +relevance:0,variants:[{ +begin:`\\b([1-9](_?[0-9])*|0)(\\.(${g}))?([eE][+-]?(${g})|r)?i?\\b`},{ +begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b" +},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{ +begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{ +begin:"\\b0(_?[0-7])+r?i?\\b"}]},l={className:"params",begin:"\\(",end:"\\)", +endsParent:!0,keywords:i},o=[t,{className:"class",beginKeywords:"class module", +end:"$|;",illegal:/=/,contains:[n.inherit(n.TITLE_MODE,{ +begin:"[A-Za-z_]\\w*(::\\w+)*(\\?|!)?"}),{begin:"<\\s*",contains:[{ +begin:"("+n.IDENT_RE+"::)?"+n.IDENT_RE,relevance:0}]}].concat(b)},{ +className:"function",begin:e(/def\s+/,(_=a+"\\s*(\\(|;|$)",e("(?=",_,")"))), +relevance:0,keywords:"def",end:"$|;",contains:[n.inherit(n.TITLE_MODE,{begin:a +}),l].concat(b)},{begin:n.IDENT_RE+"::"},{className:"symbol", +begin:n.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol", +begin:":(?!\\s)",contains:[t,{begin:a}],relevance:0},d,{className:"variable", +begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{ +className:"params",begin:/\|/,end:/\|/,relevance:0,keywords:i},{ +begin:"("+n.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{ +className:"regexp",contains:[n.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{ +begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(", +end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}] +}].concat(r,b),relevance:0}].concat(r,b);var _;c.contains=o,l.contains=o +;const E=[{begin:/^\s*=>/,starts:{end:"$",contains:o}},{className:"meta", +begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+>|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])", +starts:{end:"$",contains:o}}];return b.unshift(r),{name:"Ruby", +aliases:["rb","gemspec","podspec","thor","irb"],keywords:i,illegal:/\/\*/, +contains:[n.SHEBANG({binary:"ruby"})].concat(E).concat(b).concat(o)}}})()); +hljs.registerLanguage("rust",(()=>{"use strict";return e=>{ +const n="([ui](8|16|32|64|128|size)|f(32|64))?",t="drop i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 str char bool Box Option Result String Vec Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator Extend IntoIterator DoubleEndedIterator ExactSizeIterator SliceConcatExt ToString assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! debug_assert! debug_assert_eq! env! panic! file! format! format_args! include_bin! include_str! line! local_data_key! module_path! option_env! print! println! select! stringify! try! unimplemented! unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!" +;return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?", +keyword:"abstract as async await become box break const continue crate do dyn else enum extern false final fn for if impl in let loop macro match mod move mut override priv pub ref return self Self static struct super trait true try type typeof unsafe unsized use virtual where while yield", +literal:"true false Some None Ok Err",built_in:t},illegal:""}]}}})()); +hljs.registerLanguage("scss",(()=>{"use strict" +;const e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],t=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],i=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],r=["align-content","align-items","align-self","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","auto","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","clip-path","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-variant","font-variant-ligatures","font-variation-settings","font-weight","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inherit","initial","justify-content","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","mask","max-height","max-width","min-height","min-width","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","pointer-events","position","quotes","resize","right","src","tab-size","table-layout","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","white-space","widows","width","word-break","word-spacing","word-wrap","z-index"].reverse() +;return a=>{const n=(e=>({IMPORTANT:{className:"meta",begin:"!important"}, +HEXCOLOR:{className:"number",begin:"#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"}, +ATTRIBUTE_SELECTOR_MODE:{className:"selector-attr",begin:/\[/,end:/\]/, +illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]} +}))(a),l=o,s=i,d="@[a-z-]+",c={className:"variable", +begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b"};return{name:"SCSS",case_insensitive:!0, +illegal:"[=/|']",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{ +className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{ +className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0 +},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag", +begin:"\\b("+e.join("|")+")\\b",relevance:0},{className:"selector-pseudo", +begin:":("+s.join("|")+")"},{className:"selector-pseudo", +begin:"::("+l.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[a.CSS_NUMBER_MODE] +},{className:"attribute",begin:"\\b("+r.join("|")+")\\b"},{ +begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b" +},{begin:":",end:";", +contains:[c,n.HEXCOLOR,a.CSS_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,n.IMPORTANT] +},{begin:"@(page|font-face)",lexemes:d,keywords:"@page @font-face"},{begin:"@", +end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/, +keyword:"and or not only",attribute:t.join(" ")},contains:[{begin:d, +className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute" +},c,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,n.HEXCOLOR,a.CSS_NUMBER_MODE]}]}} +})()); +hljs.registerLanguage("shell",(()=>{"use strict";return s=>({ +name:"Shell Session",aliases:["console"],contains:[{className:"meta", +begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#]/,starts:{end:/[^\\](?=\s*$)/, +subLanguage:"bash"}}]})})()); +hljs.registerLanguage("sql",(()=>{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function r(...r){ +return r.map((r=>e(r))).join("")}function t(...r){ +return"("+r.map((r=>e(r))).join("|")+")"}return e=>{ +const n=e.COMMENT("--","$"),a=["true","false","unknown"],i=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],s=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],o=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],c=s,l=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update ","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter((e=>!s.includes(e))),u={ +begin:r(/\b/,t(...c),/\s*\(/),keywords:{built_in:c}};return{name:"SQL", +case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/, +keyword:((e,{exceptions:r,when:t}={})=>{const n=t +;return r=r||[],e.map((e=>e.match(/\|\d+$/)||r.includes(e)?e:n(e)?e+"|0":e)) +})(l,{when:e=>e.length<3}),literal:a,type:i, +built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"] +},contains:[{begin:t(...o),keywords:{$pattern:/[\w\.]+/,keyword:l.concat(o), +literal:a,type:i}},{className:"type", +begin:t("double precision","large object","with timezone","without timezone") +},u,{className:"variable",begin:/@[a-z0-9]+/},{className:"string",variants:[{ +begin:/'/,end:/'/,contains:[{begin:/''/}]}]},{begin:/"/,end:/"/,contains:[{ +begin:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{className:"operator", +begin:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}})()); +hljs.registerLanguage("swift",(()=>{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function n(e){return a("(?=",e,")")} +function a(...n){return n.map((n=>e(n))).join("")}function t(...n){ +return"("+n.map((n=>e(n))).join("|")+")"} +const i=e=>a(/\b/,e,/\w$/.test(e)?/\b/:/\B/),s=["Protocol","Type"].map(i),u=["init","self"].map(i),c=["Any","Self"],r=["associatedtype","async","await",/as\?/,/as!/,"as","break","case","catch","class","continue","convenience","default","defer","deinit","didSet","do","dynamic","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","lazy","let","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],o=["false","nil","true"],l=["assignment","associativity","higherThan","left","lowerThan","none","right"],m=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warn_unqualified_access","#warning"],d=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],p=t(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),F=t(p,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),b=a(p,F,"*"),h=t(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),f=t(h,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),w=a(h,f,"*"),y=a(/[A-Z]/,f,"*"),g=["autoclosure",a(/convention\(/,t("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",a(/objc\(/,w,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","testable","UIApplicationMain","unknown","usableFromInline"],E=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"] +;return e=>{const p={match:/\s+/,relevance:0},h=e.COMMENT("/\\*","\\*/",{ +contains:["self"]}),v=[e.C_LINE_COMMENT_MODE,h],N={className:"keyword", +begin:a(/\./,n(t(...s,...u))),end:t(...s,...u),excludeBegin:!0},A={ +match:a(/\./,t(...r)),relevance:0 +},C=r.filter((e=>"string"==typeof e)).concat(["_|0"]),_={variants:[{ +className:"keyword", +match:t(...r.filter((e=>"string"!=typeof e)).concat(c).map(i),...u)}]},D={ +$pattern:t(/\b\w+/,/#\w+/),keyword:C.concat(m),literal:o},B=[N,A,_],k=[{ +match:a(/\./,t(...d)),relevance:0},{className:"built_in", +match:a(/\b/,t(...d),/(?=\()/)}],M={match:/->/,relevance:0},S=[M,{ +className:"operator",relevance:0,variants:[{match:b},{match:`\\.(\\.|${F})+`}] +}],x="([0-9a-fA-F]_*)+",I={className:"number",relevance:0,variants:[{ +match:"\\b(([0-9]_*)+)(\\.(([0-9]_*)+))?([eE][+-]?(([0-9]_*)+))?\\b"},{ +match:`\\b0x(${x})(\\.(${x}))?([pP][+-]?(([0-9]_*)+))?\\b`},{ +match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(e="")=>({ +className:"subst",variants:[{match:a(/\\/,e,/[0\\tnr"']/)},{ +match:a(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),T=(e="")=>({className:"subst", +match:a(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}),L=(e="")=>({className:"subst", +label:"interpol",begin:a(/\\/,e,/\(/),end:/\)/}),P=(e="")=>({begin:a(e,/"""/), +end:a(/"""/,e),contains:[O(e),T(e),L(e)]}),$=(e="")=>({begin:a(e,/"/), +end:a(/"/,e),contains:[O(e),L(e)]}),K={className:"string", +variants:[P(),P("#"),P("##"),P("###"),$(),$("#"),$("##"),$("###")]},j={ +match:a(/`/,w,/`/)},z=[j,{className:"variable",match:/\$\d+/},{ +className:"variable",match:`\\$${f}+`}],q=[{match:/(@|#)available/, +className:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:E, +contains:[...S,I,K]}]}},{className:"keyword",match:a(/@/,t(...g))},{ +className:"meta",match:a(/@/,w)}],U={match:n(/\b[A-Z]/),relevance:0,contains:[{ +className:"type", +match:a(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,f,"+") +},{className:"type",match:y,relevance:0},{match:/[?!]+/,relevance:0},{ +match:/\.\.\./,relevance:0},{match:a(/\s+&\s+/,n(y)),relevance:0}]},Z={ +begin://,keywords:D,contains:[...v,...B,...q,M,U]};U.contains.push(Z) +;const G={begin:/\(/,end:/\)/,relevance:0,keywords:D,contains:["self",{ +match:a(w,/\s*:/),keywords:"_|0",relevance:0 +},...v,...B,...k,...S,I,K,...z,...q,U]},H={beginKeywords:"func",contains:[{ +className:"title",match:t(j.match,w,b),endsParent:!0,relevance:0},p]},R={ +begin://,contains:[...v,U]},V={begin:/\(/,end:/\)/,keywords:D, +contains:[{begin:t(n(a(w,/\s*:/)),n(a(w,/\s+/,w,/\s*:/))),end:/:/,relevance:0, +contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:w}] +},...v,...B,...S,I,K,...q,U,G],endsParent:!0,illegal:/["']/},W={ +className:"function",match:n(/\bfunc\b/),contains:[H,R,V,p],illegal:[/\[/,/%/] +},X={className:"function",match:/\b(subscript|init[?!]?)\s*(?=[<(])/,keywords:{ +keyword:"subscript init init? init!",$pattern:/\w+[?!]?/},contains:[R,V,p], +illegal:/\[|%/},J={beginKeywords:"operator",end:e.MATCH_NOTHING_RE,contains:[{ +className:"title",match:b,endsParent:!0,relevance:0}]},Q={ +beginKeywords:"precedencegroup",end:e.MATCH_NOTHING_RE,contains:[{ +className:"title",match:y,relevance:0},{begin:/{/,end:/}/,relevance:0, +endsParent:!0,keywords:[...l,...o],contains:[U]}]};for(const e of K.variants){ +const n=e.contains.find((e=>"interpol"===e.label));n.keywords=D +;const a=[...B,...k,...S,I,K,...z];n.contains=[...a,{begin:/\(/,end:/\)/, +contains:["self",...a]}]}return{name:"Swift",keywords:D,contains:[...v,W,X,{ +className:"class",beginKeywords:"struct protocol class extension enum", +end:"\\{",excludeEnd:!0,keywords:D,contains:[e.inherit(e.TITLE_MODE,{ +begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/}),...B]},J,Q,{ +beginKeywords:"import",end:/$/,contains:[...v],relevance:0 +},...B,...k,...S,I,K,...z,...q,U,G]}}})()); +hljs.registerLanguage("typescript",(()=>{"use strict" +;const e="[A-Za-z$_][0-9A-Za-z$_]*",n=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],a=["true","false","null","undefined","NaN","Infinity"],s=[].concat(["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],["arguments","this","super","console","window","document","localStorage","module","global"],["Intl","DataView","Number","Math","Date","String","RegExp","Object","Function","Boolean","Error","Symbol","Set","Map","WeakSet","WeakMap","Proxy","Reflect","JSON","Promise","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Float32Array","Array","Uint8Array","Uint8ClampedArray","ArrayBuffer","BigInt64Array","BigUint64Array","BigInt"],["EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"]) +;function t(e){return r("(?=",e,")")}function r(...e){return e.map((e=>{ +return(n=e)?"string"==typeof n?n:n.source:null;var n})).join("")}return i=>{ +const c={$pattern:e, +keyword:n.concat(["type","namespace","typedef","interface","public","private","protected","implements","declare","abstract","readonly"]), +literal:a, +built_in:s.concat(["any","void","number","boolean","string","object","never","enum"]) +},o={className:"meta",begin:"@[A-Za-z$_][0-9A-Za-z$_]*"},l=(e,n,a)=>{ +const s=e.contains.findIndex((e=>e.label===n)) +;if(-1===s)throw Error("can not find mode to replace");e.contains.splice(s,1,a) +},b=(i=>{const c=e,o={begin:/<[A-Za-z0-9\\._:-]+/, +end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,n)=>{ +const a=e[0].length+e.index,s=e.input[a];"<"!==s?">"===s&&(((e,{after:n})=>{ +const a="", +returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{ +begin:i.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0 +},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:f}]}] +},{begin:/,/,relevance:0},{className:"",begin:/\s/,end:/\s*/,skip:!0},{ +variants:[{begin:"<>",end:""},{begin:o.begin,"on:begin":o.isTrulyOpeningTag, +end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0, +contains:["self"]}]}],relevance:0},{className:"function", +beginKeywords:"function",end:/[{;]/,excludeEnd:!0,keywords:l, +contains:["self",i.inherit(i.TITLE_MODE,{begin:c}),A],illegal:/%/},{ +beginKeywords:"while if switch catch for"},{className:"function", +begin:i.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{", +returnBegin:!0,contains:[A,i.inherit(i.TITLE_MODE,{begin:c})]},{variants:[{ +begin:"\\."+c},{begin:"\\$"+c}],relevance:0},{className:"class", +beginKeywords:"class",end:/[{;=]/,excludeEnd:!0,illegal:/[:"[\]]/,contains:[{ +beginKeywords:"extends"},i.UNDERSCORE_TITLE_MODE]},{begin:/\b(?=constructor)/, +end:/[{;]/,excludeEnd:!0,contains:[i.inherit(i.TITLE_MODE,{begin:c}),"self",A] +},{begin:"(get|set)\\s+(?="+c+"\\()",end:/\{/,keywords:"get set", +contains:[i.inherit(i.TITLE_MODE,{begin:c}),{begin:/\(\)/},A]},{begin:/\$[(.]/}] +}})(i) +;return Object.assign(b.keywords,c),b.exports.PARAMS_CONTAINS.push(o),b.contains=b.contains.concat([o,{ +beginKeywords:"namespace",end:/\{/,excludeEnd:!0},{beginKeywords:"interface", +end:/\{/,excludeEnd:!0,keywords:"interface extends" +}]),l(b,"shebang",i.SHEBANG()),l(b,"use_strict",{className:"meta",relevance:10, +begin:/^\s*['"]use strict['"]/ +}),b.contains.find((e=>"function"===e.className)).relevance=0,Object.assign(b,{ +name:"TypeScript",aliases:["ts","tsx"]}),b}})()); +hljs.registerLanguage("vbnet",(()=>{"use strict";function e(e){ +return e?"string"==typeof e?e:e.source:null}function n(...n){ +return n.map((n=>e(n))).join("")}function t(...n){ +return"("+n.map((n=>e(n))).join("|")+")"}return e=>{ +const a=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,s=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,r=/\d{1,2}(:\d{1,2}){1,2}/,o={ +className:"literal",variants:[{begin:n(/# */,t(i,a),/ *#/)},{ +begin:n(/# */,r,/ *#/)},{begin:n(/# */,s,/ *#/)},{ +begin:n(/# */,t(i,a),/ +/,t(s,r),/ *#/)}]},l=e.COMMENT(/'''/,/$/,{contains:[{ +className:"doctag",begin:/<\/?/,end:/>/}]}),c=e.COMMENT(null,/$/,{variants:[{ +begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET", +aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{ +keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield", +built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort", +type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort", +literal:"true false nothing"}, +illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{ +className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/, +end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o,{className:"number",relevance:0, +variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/ +},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{ +begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{ +className:"label",begin:/^\w+:/},l,c,{className:"meta", +begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/, +end:/$/,keywords:{ +"meta-keyword":"const disable else elseif enable end externalsource if region then" +},contains:[c]}]}}})()); +hljs.registerLanguage("yaml",(()=>{"use strict";return e=>{ +var n="true false yes no null",a="[\\w#;/?:@&=+$,.~*'()[\\]]+",s={ +className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/ +},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable", +variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(s,{ +variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),l={ +end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},t={begin:/\{/, +end:/\}/,contains:[l],illegal:"\\n",relevance:0},g={begin:"\\[",end:"\\]", +contains:[l],illegal:"\\n",relevance:0},b=[{className:"attr",variants:[{ +begin:"\\w[\\w :\\/.-]*:(?=[ \t]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ \t]|$)'},{ +begin:"'\\w[\\w :\\/.-]*':(?=[ \t]|$)"}]},{className:"meta",begin:"^---\\s*$", +relevance:10},{className:"string", +begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{ +begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0, +relevance:0},{className:"type",begin:"!\\w+!"+a},{className:"type", +begin:"!<"+a+">"},{className:"type",begin:"!"+a},{className:"type",begin:"!!"+a +},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta", +begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)", +relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{ +className:"number", +begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b" +},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},t,g,s],r=[...b] +;return r.pop(),r.push(i),l.contains=r,{name:"YAML",case_insensitive:!0, +aliases:["yml"],contains:b}}})()); \ No newline at end of file diff --git a/deliverables/Coverage/htmlReport/js/highlightjs-line-numbers.min.js b/deliverables/Coverage/htmlReport/js/highlightjs-line-numbers.min.js new file mode 100644 index 0000000..8548576 --- /dev/null +++ b/deliverables/Coverage/htmlReport/js/highlightjs-line-numbers.min.js @@ -0,0 +1,24 @@ +/* +The MIT License (MIT) + +Copyright (c) 2017 Yauheni Pakala + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +!function(r,o){"use strict";var e,i="hljs-ln",l="hljs-ln-line",h="hljs-ln-code",s="hljs-ln-numbers",c="hljs-ln-n",m="data-line-number",a=/\r\n|\r|\n/g;function u(e){for(var n=e.toString(),t=e.anchorNode;"TD"!==t.nodeName;)t=t.parentNode;for(var r=e.focusNode;"TD"!==r.nodeName;)r=r.parentNode;var o=parseInt(t.dataset.lineNumber),a=parseInt(r.dataset.lineNumber);if(o==a)return n;var i,l=t.textContent,s=r.textContent;for(a
{6}',[l,s,c,m,h,o+n.startFrom,0{1}',[i,r])}return e}(e.innerHTML,o)}function v(e){var n=e.className;if(/hljs-/.test(n)){for(var t=g(e.innerHTML),r=0,o="";r{1}
\n',[n,0 + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..d41ab41 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..5a4a6e2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..8f87b87 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..e7cf41a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE.html new file mode 100644 index 0000000..037a43c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..a7f816a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..dcfb312 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..6e78f3e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..27997af --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,356 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14 + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14 + + 0% + + + (0/9) + + + + 0% + + + (0/67) + + + + 0% + + + (0/149) + + + + 0% + + + (0/394) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/23) + +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
GameEventProcessor + + 0% + + + (0/2) + + + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/12) + +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/9) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-1.html new file mode 100644 index 0000000..99363ec --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-1.html @@ -0,0 +1,161 @@ + + + + + + + + Coverage Report > ClientLauncherGUI + + + + + + +
+ + +

Coverage Summary for Class: ClientLauncherGUI (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + + + + + + + + + +
Class + Method, % + + Line, % +
ClientLauncherGUI + + 0% + + + (0/2) + + + + 0% + + + (0/4) + +
ClientLauncherGUI$GUIApp + + 0% + + + (0/2) + + + + 0% + + + (0/5) + +
Total + + 0% + + + (0/4) + + + + 0% + + + (0/9) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.View.GUI.GUI;
+ import javafx.application.Application;
+ import javafx.stage.Stage;
+ 
+ /** Entry point for launching the game client with the JavaFX GUI. */
+ public class ClientLauncherGUI {
+ 
+     /**
+      * Launches the GUI application.
+      *
+      * @param args command-line arguments passed to the JavaFX runtime.
+      */
+     public static void main(String[] args) {
+         System.setProperty("glass.gtk.uiScale", "1.0");
+         System.setProperty("glass.win.uiScale", "1.0");
+         Application.launch(GUIApp.class, args);
+     }
+     //TODO
+     public static class GUIApp extends Application {
+         @Override
+         public void start(Stage stage) throws Exception {
+             GUI view = new GUI();
+             ClientController controller = new ClientController(view);
+             view.setController(controller);
+             view.start(stage);
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-2.html new file mode 100644 index 0000000..1e6fae1 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-2.html @@ -0,0 +1,436 @@ + + + + + + + + Coverage Report > ClientLauncherTUI + + + + + + +
+ + +

Coverage Summary for Class: ClientLauncherTUI (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientLauncherTUI + + 0% + + + (0/1) + + + + 0% + + + (0/11) + + + + 0% + + + (0/67) + + + + 0% + + + (0/142) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.InterfaceResolver;
+ import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
+ import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
+ import it.polimi.ingsw.gc14.View.TUI.TUI;
+ 
+ import org.jline.builtins.Completers.TreeCompleter;
+ import org.jline.reader.*;
+ import org.jline.reader.impl.completer.StringsCompleter;
+ import org.jline.terminal.Terminal;
+ import org.jline.terminal.TerminalBuilder;
+ 
+ import java.io.IOException;
+ import java.io.PrintStream;
+ import java.nio.charset.StandardCharsets;
+ 
+ import static org.jline.builtins.Completers.TreeCompleter.node;
+ 
+ /**
+  * Entry point for the TUI-based game client.
+  * Handles login, connects to the server, and drives the JLine-powered command loop.
+  */
+ public class ClientLauncherTUI {
+     //TODO
+     private TUI view;
+     //TODO
+     private Terminal terminal;
+     //TODO
+     private LineReader gameReader;
+     //TODO
+     private String currentUsername = "";
+ 
+     private static final String BUILDING_DETAILS =
+         "ID  0 — Each time you complete a set of 6 different Character cards, take 5 \uD83C\uDF56. (Sets completed before acquiring don't count.)\n" +
+         "ID  1 — During the Sustenance Event, pay 1 less \uD83C\uDF56 for each Artist/Inventor/Gatherer in your tribe.\n" +
+         "ID  2 — During the Shamanic Ritual Event, you do not lose Prestige Points if you have fewer ⭐ than all other players.\n" +
+         "ID  3 — When you move your Totem to a Food-bonus space, take 1 extra \uD83C\uDF56. If placed last, pay 1 \uD83C\uDF56 normally (no effect).\n" +
+         "ID  4 — Each time you obtain a pair of identical Inventors (same icon), take 3 \uD83C\uDF56. (Pairs owned before don't count.)\n" +
+         "ID  5 — During the Shamanic Ritual Event, your tribe has 3 additional ⭐ icons.\n" +
+         "ID  6 — During the Shamanic Ritual Event, if you have more ⭐ than any other player, gain double Prestige. Ties still count.\n" +
+         "ID  7 — During the Hunt Event, take 1 \uD83C\uDF56 and gain 1 extra Prestige Point for each Hunter in your tribe.\n" +
+         "ID  8 — At end of game, gain double the Prestige Points shown on Builder cards in your tribe.\n" +
+         "ID  9 — During the Cave Paintings Event, take 1 \uD83C\uDF56 for each Artist in your tribe.\n" +
+         "ID 10 — At end of game, gain 6 Prestige Points for each complete set of 6 different Character cards.\n" +
+         "ID 11 — At end of game, gain the indicated Prestige Points for each Character card of the indicated type.\n" +
+         "ID 12 — After all Totems return to Turn Order (before End of Round), take 1 Character or 1 Building card from the top row (paying its cost).\n" +
+         "ID 13 — At end of game, gain 25 Prestige Points.";
+ 
+     private static final String EVENT_DETAILS =
+         "SUSTENANCE — Pay 1 \uD83C\uDF56 per Character (Buildings don't count). If you can't feed all Characters, lose the\n" +
+         "  Prestige Points shown on the card for each one you couldn't feed. Each Gatherer gives a 3\uD83C\uDF56 discount.\n" +
+         "  You cannot choose to lose PP to avoid paying Food. Sustenance resolves last if multiple Events occur.\n" +
+         "\n" +
+         "HUNT — Take 1 \uD83C\uDF56 and gain the Prestige Points shown on the card for each Hunter in your tribe.\n" +
+         "\n" +
+         "SHAMANIC RITUAL — Player with the most \uD83C\uDF1F icons gains the Prestige Points on the card.\n" +
+         "  Player with the fewest \uD83C\uDF1F icons loses those Prestige Points. In case of a tie, all tied players gain/lose.\n" +
+         "\n" +
+         "CAVE PAINTINGS — If you have fewer Artists than the top-line threshold, lose the indicated Prestige Points.\n" +
+         "  If you meet the bottom-line threshold, gain the indicated Prestige Points for each Artist in your tribe.";
+ 
+     private static final String CHARACTER_DETAILS =
+         "INVENTORS — At end of game, gain PP equal to (number of Inventors) × (number of different Invention icons).\n" +
+         "  There are 10 different Invention icons.\n" +
+         "\n" +
+         "GATHERERS — During Sustenance, each Gatherer gives a 3\uD83C\uDF56 discount on what you owe.\n" +
+         "  Note: you do not take any Food from Gatherers under any circumstances.\n" +
+         "\n" +
+         "SHAMANS — Each Shaman shows 1–3 \uD83C\uDF1F icons. During Shamanic Ritual, majority = gain PP; minority = lose PP.\n" +
+         "\n" +
+         "BUILDERS — During the game, each Builder reduces the \uD83C\uDF56 cost of every Building card by the amount\n" +
+         "  shown in the top-right corner. At end of game, each Builder gives the PP shown in the bottom-left corner.\n" +
+         "\n" +
+         "ARTISTS — During Cave Paintings, gain or lose PP based on Artist count (see 'details events').\n" +
+         "  At end of game, gain 10 PP for every 2 Artists in your tribe.\n" +
+         "\n" +
+         "HUNTERS — Adding a Hunter without the \uD83C\uDF56 icon: nothing. Adding a Hunter WITH the \uD83C\uDF56 icon:\n" +
+         "  immediately take 1 \uD83C\uDF56 for each Hunter in your tribe (with or without the icon).\n" +
+         "  During Hunt Event, take \uD83C\uDF56 and gain PP based on your Hunter count (see 'details events').";
+     //TODO
+     public static void main(String[] args) throws InterruptedException {
+         new ClientLauncherTUI().start();
+     }
+ 
+     /**
+      * Starts the TUI client. Creates a JLine terminal, loops through login → game → rematch.
+      *
+      * @throws InterruptedException if the thread is interrupted while waiting.
+      */
+     private void start() throws InterruptedException {
+         try {
+             System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
+             System.setErr(new PrintStream(System.err, true, StandardCharsets.UTF_8));
+             terminal = TerminalBuilder.builder()
+                     .system(true)
+                     .encoding(StandardCharsets.UTF_8)
+                     .build();
+         } catch (IOException e) {
+             System.err.println("Could not initialise terminal: " + e.getMessage());
+             return;
+         }
+         terminal.writer().print("\033[H\033[2J");
+         terminal.writer().flush();
+ 
+         view = new TUI(null);
+         ClientController controller = new ClientController(view);
+         gameReader = buildGameReader();
+         view.setLineReader(gameReader);
+ 
+         while (true) {
+             if (!doLogin(controller)) continue;
+ 
+             while (controller.getClient() != null) {
+                 String prompt = buildPrompt(controller);
+                 String line;
+                 try {
+                     line = gameReader.readLine(prompt);
+                 } catch (UserInterruptException e) {
+                     safeQuit(controller);
+                     return;
+                 } catch (EndOfFileException e) {
+                     safeQuit(controller);
+                     return;
+                 }
+                 if (line == null || line.isBlank()) continue;
+                 boolean rematch = handleCommand(line.trim(), controller);
+                 if (rematch) break;
+             }
+         }
+     }
+     //TODO
+     private boolean doLogin(ClientController controller) {
+         LineReader loginReader = LineReaderBuilder.builder()
+                 .terminal(terminal)
+                 .completer(new StringsCompleter("rmi", "tcp"))
+                 .build();
+         LineReader ipReader = LineReaderBuilder.builder()
+                 .terminal(terminal)
+                 .completer(new StringsCompleter("localhost"))
+                 .build();
+ 
+         String username, networkStr, ip;
+         int nPlayers;
+ 
+         try {
+             username    = loginReader.readLine("Username: ").trim();
+             nPlayers    = Integer.parseInt(loginReader.readLine("Number of players [2-5]: ").trim());
+             networkStr  = loginReader.readLine("Network [rmi/tcp]: ").trim().toLowerCase();
+             ip          = ipReader.readLine("Server IP [localhost]: ").trim();
+             if (ip.isEmpty()) ip = "localhost";
+         } catch (UserInterruptException | EndOfFileException e) {
+             System.exit(0);
+             return false;
+         } catch (NumberFormatException e) {
+             System.out.println("Invalid number of players.");
+             return false;
+         }
+ 
+         currentUsername = username;
+         view.setUsername(username);
+         controller.setMyUsername(username);
+ 
+         if (networkStr.equals("rmi")) {
+             String myIP;
+             try {
+                 myIP = InterfaceResolver.resolveLocalInterface(ip);
+             } catch (Exception e) {
+                 System.out.println("Cannot resolve local interface: " + e.getMessage());
+                 return false;
+             }
+             System.setProperty("java.rmi.server.hostname", myIP);
+             RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP);
+             ErrorType err = client.connect(username, nPlayers);
+             if (err != null) {
+                 terminal.writer().print("\033[H\033[2J");
+                 terminal.writer().flush();
+                 System.out.println("Errore: " + err);
+                 return false;
+             }
+             System.out.println("Connected via RMI.");
+             controller.setClient(client);
+ 
+         } else if (networkStr.equals("tcp")) {
+             TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
+             ErrorType err = client.connect(username, nPlayers);
+             if (err != null) {
+                 terminal.writer().print("\033[H\033[2J");
+                 terminal.writer().flush();
+                 System.out.println("Errore: " + err);
+                 return false;
+             }
+             System.out.println("Connected via TCP.");
+             controller.setClient(client);
+ 
+         } else {
+             System.out.println("Unknown network type '" + networkStr + "'. Use rmi or tcp.");
+             return false;
+         }
+         return true;
+     }
+     //TODO
+     private LineReader buildGameReader() {
+         Completer completer = new TreeCompleter(
+                 node("slot"),
+                 node("draw",
+                         node("upper",
+                                 node("tribe"),
+                                 node("building")),
+                         node("lower",
+                                 node("tribe"),
+                                 node("building"))),
+                 node("totem"),
+                 node("skip"),
+                 node("render"),
+                 node("help"),
+                 node("details", node("buildings"), node("events"), node("characters")),
+                 node("rematch"),
+                 node("quit")
+         );
+         return LineReaderBuilder.builder()
+                 .terminal(terminal)
+                 .completer(completer)
+                 .option(LineReader.Option.DISABLE_EVENT_EXPANSION, true)
+                 .build();
+     }
+     //TODO
+     private String buildPrompt(ClientController controller) {
+         return currentUsername.isEmpty() ? "> " : currentUsername + "> ";
+     }
+ 
+     /** Returns {@code true} when the caller should break out of the game loop (rematch requested). */
+     private boolean handleCommand(String line, ClientController controller) {
+         String[] parts = line.split("\\s+");
+         String cmd = parts[0].toLowerCase();
+ 
+         switch (cmd) {
+             case "slot" -> {
+                 int pos = parsePos(parts, 1);
+                 if (pos >= 0) controller.slotChoice(pos);
+             }
+             case "draw"   -> handleDraw(parts, controller);
+             case "totem" -> {
+                 int pos = parsePos(parts, 1);
+                 if (pos >= 0) controller.totemChoice(pos);
+             }
+             case "skip"   -> controller.skipTurn();
+             case "render" -> handleRender(parts);
+             case "help"    -> gameReader.printAbove("Commands: slot, draw, totem, skip, render, help, details, rematch, quit");
+             case "details" -> {
+                 if (parts.length > 1 && parts[1].equalsIgnoreCase("buildings"))
+                     gameReader.printAbove(BUILDING_DETAILS);
+                 else if (parts.length > 1 && parts[1].equalsIgnoreCase("events"))
+                     gameReader.printAbove(EVENT_DETAILS);
+                 else if (parts.length > 1 && parts[1].equalsIgnoreCase("characters"))
+                     gameReader.printAbove(CHARACTER_DETAILS);
+                 else
+                     gameReader.printAbove("Usage: details buildings | details events | details characters");
+             }
+             case "rematch" -> {
+                 if (controller.getMiniModel() == null
+                         || !controller.getMiniModel().currentState.getGameStage().equals(GameStages.ENDED)) {
+                     System.out.println("Game not ended yet. Use 'quit' to disconnect.");
+                     return false;
+                 }
+                 controller.disconnect();
+                 controller.setClient(null);
+                 controller.setModel(null);
+                 return true;
+             }
+             case "quit" -> {
+                 safeQuit(controller);
+                 System.exit(0);
+             }
+             default -> view.showError(ErrorType.GENERIC_ERROR, "Unknown command: " + cmd);
+         }
+         return false;
+     }
+     //TODO
+     private void handleDraw(String[] parts, ClientController controller) {
+         if (parts.length < 4) {
+             view.showError(ErrorType.GENERIC_ERROR, "Usage: draw upper|lower tribe|building <pos>");
+             return;
+         }
+         boolean upper = parts[1].equalsIgnoreCase("upper");
+         boolean tribe = parts[2].equalsIgnoreCase("tribe");
+         int pos = parsePos(parts, 3);
+         if (pos < 0) return;
+ 
+         if (upper && tribe)  controller.drawUpperTribeCard(pos);
+         else if (upper)      controller.drawUpperBuildingCard(pos);
+         else if (tribe)      controller.drawLowerTribeCard(pos);
+         else                 controller.drawLowerBuildingCard(pos);
+     }
+     //TODO
+     private void handleRender(String[] parts) {
+         view.renderBoard();
+     }
+     //TODO
+     private int parsePos(String[] parts, int idx) {
+         if (parts.length <= idx) {
+             view.showError(ErrorType.GENERIC_ERROR, "Missing position argument.");
+             return -1;
+         }
+         try {
+             return Integer.parseInt(parts[idx]);
+         } catch (NumberFormatException e) {
+             view.showError(ErrorType.GENERIC_ERROR,
+                     "Invalid position '" + parts[idx] + "' — expected integer.");
+             return -1;
+         }
+     }
+     //TODO
+     private void safeQuit(ClientController controller) {
+         if (controller.getClient() != null) controller.disconnect();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-3.html new file mode 100644 index 0000000..5302623 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-3.html @@ -0,0 +1,126 @@ + + + + + + + + Coverage Report > ErrorType + + + + + + +
+ + +

Coverage Summary for Class: ErrorType (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
ErrorType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/12) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ /** Enumeration of error types that can be returned by server-side operations. */
+ public enum ErrorType {
+     USER_NOT_FOUND("User not found"),
+     USERNAME_ALREADY_USED("Username is already in use"),
+     USER_ALREADY_CONNECTED("User is already connected"),
+     WRONG_PLAYER_NUMBER("Wrong player number"),
+     SERVER_CRASHED("Server crashed"),
+     GENERIC_ERROR("Generic error"),
+     GAME_ALREADY_STARTED("Game already started"),
+     WRONG_ACTION("Wrong action");
+     //TODO
+     private final String description;
+     ErrorType(String description) {
+         this.description = description;
+     }
+     @Override
+     public String toString() {
+         return description;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-4.html new file mode 100644 index 0000000..7dfdab3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-4.html @@ -0,0 +1,523 @@ + + + + + + + + Coverage Report > GameEventProcessor + + + + + + +
+ + +

Coverage Summary for Class: GameEventProcessor (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Class + Method, % + + Branch, % + + Line, % +
GameEventProcessor + + 0% + + + (0/19) + + + + 0% + + + (0/48) + + + + 0% + + + (0/107) + +
GameEventProcessor$1 + + 0% + + + (0/1) + + + + 0% + + + (0/1) + +
Total + + 0% + + + (0/20) + + + + 0% + + + (0/48) + + + + 0% + + + (0/108) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.Network.CompositeClientBroadcaster;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.concurrent.*;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * Processes game events from the action queue and routes each one
+  * based on the current game state.
+  *
+  * <p>The three top-level states that determine routing are:
+  * <ul>
+  *   <li><b>Inactive</b> – no game model is present, or the game has ended.
+  *       Only disconnection clean-up is performed.</li>
+  *   <li><b>Suspended</b> – a forfeit timer is running because exactly one
+  *       player remains online. Only reconnection events are accepted.</li>
+  *   <li><b>Active</b> – normal gameplay; every event is applied, saved,
+  *       and broadcast.</li>
+  * </ul>
+  *
+  * <p>This class is not thread-safe by itself: it relies on the caller
+  * (the game loop in {@code ServerLauncher}) to drive it from a single
+  * thread via {@link #doFirstEvent()}.
+  */
+ public class GameEventProcessor {
+ 
+     private final BlockingQueue<NetworkEvent> actionQueue;
+     private final GameController gameController;
+     private final LimitedMap<String, Boolean> playerList;
+     private final CompositeClientBroadcaster broadcaster;
+     private final SaveManager saveManager;
+ 
+     /** Single-thread executor used exclusively for the forfeit timer. Daemon so it does not block JVM shutdown. */
+     private final ScheduledExecutorService timerExecutor =
+             Executors.newSingleThreadScheduledExecutor(r -> {
+                 Thread t = new Thread(r, "forfeit-timer");
+                 t.setDaemon(true);
+                 return t;
+             });
+ 
+     /**
+      * Handle to the running forfeit timer, or {@code null} when no timer is active.
+      * A non-null value signals that the game is in the {@em suspended} state.
+      */
+     private ScheduledFuture<?> disconnectionTimer;
+ 
+     /**
+      * Constructs a {@code GameEventProcessor} with all required dependencies.
+      *
+      * @param actionQueue    the queue from which incoming events are consumed.
+      * @param gameController the server-side game controller.
+      * @param playerList     the shared map tracking each player's online status.
+      * @param broadcaster    the broadcaster used to notify all connected clients.
+      * @param saveManager    the save manager used to persist the game state.
+      */
+     public GameEventProcessor(
+             BlockingQueue<NetworkEvent> actionQueue,
+             GameController gameController,
+             LimitedMap<String, Boolean> playerList,
+             CompositeClientBroadcaster broadcaster,
+             SaveManager saveManager) {
+         this.actionQueue    = actionQueue;
+         this.gameController = gameController;
+         this.playerList     = playerList;
+         this.broadcaster    = broadcaster;
+         this.saveManager    = saveManager;
+     }
+ 
+     // ── Public entry point ────────────────────────────────────────────────────
+ 
+     /**
+      * Blocks until one event is available in the queue, then routes it to the
+      * appropriate handler based on the current game state.
+      *
+      * @throws InterruptedException if the thread is interrupted while waiting
+      *                              for the next event.
+      */
+     public void doFirstEvent() throws InterruptedException {
+         NetworkEvent event = actionQueue.take();
+ 
+         if (!isGameActive()) {
+             handleInactiveGame(event);
+         } else if (isSuspended()) {
+             handleSuspendedGame(event);
+         } else {
+             applyAndBroadcast(event);
+         }
+     }
+ 
+     // ── State guards ──────────────────────────────────────────────────────────
+ 
+     /**
+      * Returns {@code true} when there is an ongoing game that has not yet ended.
+      */
+     private boolean isGameActive() {
+         Game model = gameController.getModel();
+         return model != null
+                 && model.getCurrentState().getGameStage() != GameStages.ENDED;
+     }
+ 
+     /**
+      * Returns {@code true} when the forfeit timer is running, meaning only one
+      * player is currently online and the game is waiting for a reconnection.
+      */
+     private boolean isSuspended() {
+         return disconnectionTimer != null;
+     }
+ 
+     // ── Inactive game path ────────────────────────────────────────────────────
+ 
+     /**
+      * Handles events that arrive when no active game exists (not yet started,
+      * or already ended). Only disconnection clean-up is relevant here.
+      *
+      * @param event the incoming event.
+      */
+     private void handleInactiveGame(NetworkEvent event) {
+         if (event.getEventType() != EventType.DISCONNECTED_PLAYER) return;
+ 
+         synchronized (gameController) {
+             playerList.remove(event.getUsername());
+             if (playerList.isEmpty()) {
+                 gameController.setModel(null);
+                 System.out.println("\n!!! Player list is now empty, ready for a new game init !!!\n");
+             }
+         }
+     }
+ 
+     // ── Suspended game path ───────────────────────────────────────────────────
+ 
+     /**
+      * Routes events while the game is suspended waiting for a reconnection.
+      * <ul>
+      *   <li>A second disconnection while suspended means no player remains
+      *       online: the game is aborted entirely.</li>
+      *   <li>Any non-reconnection event is rejected with an error.</li>
+      *   <li>A reconnection event is allowed through to {@link #applyAndBroadcast}.</li>
+      * </ul>
+      *
+      * @param event the incoming event.
+      */
+     private void handleSuspendedGame(NetworkEvent event) {
+         switch (event.getEventType()) {
+             case DISCONNECTED_PLAYER -> abortGame();
+             case RECONNECT_PLAYER    -> applyAndBroadcast(event);
+             default                  -> rejectEvent(event);
+         }
+     }
+ 
+     /**
+      * Cancels the forfeit timer, clears the player list, and resets the model.
+      * Called when the last remaining player disconnects while the game is suspended.
+      */
+     private void abortGame() {
+         disconnectionTimer.cancel(true);
+         disconnectionTimer = null;
+         playerList.clear();
+         gameController.setModel(null);
+         System.out.println("\n!!! All players disconnected — game aborted, ready for a new game init !!!\n");
+     }
+ 
+     /**
+      * Marks the event as an error and broadcasts it back to the requesting
+      * player. Used to reject actions that are not permitted in the current state.
+      *
+      * @param event the event to reject.
+      */
+     private void rejectEvent(NetworkEvent event) {
+         event.setIsError(true);
+         broadcaster.notifyAll(event);
+     }
+ 
+     // ── Active game path ──────────────────────────────────────────────────────
+ 
+     /**
+      * Applies the event to the game controller, saves the updated state,
+      * and broadcasts the result to connected clients.
+      *
+      * <p>The entire method body is synchronized on {@code gameController} to
+      * prevent concurrent modification of the game model by the network threads.
+      *
+      * @param event the event to apply.
+      */
+     private void applyAndBroadcast(NetworkEvent event) {
+         synchronized (gameController) {
+             int roundBefore = gameController.getModel().getCurrentState().getRound();
+ 
+             event.setIsError(!event.apply(gameController));
+             Game game = gameController.getModel();
+ 
+             if (event.isError()) {
+                 broadcaster.notifyAll(event);
+                 return;
+             }
+ 
+             cancelForfeitTimerIfReconnect(event);
+ 
+             if (!saveManager.save(game)) {
+                 System.out.println("\n!!! Save failed !!!\n");
+             }
+ 
+             // During the lobby phase a disconnection only removes the player
+             // from the list; no broadcast is needed.
+             if (event.getEventType() == EventType.DISCONNECTED_PLAYER
+                     && game.getCurrentState().getGameStage() == GameStages.WAITING) {
+                 playerList.remove(event.getUsername());
+                 return;
+             }
+ 
+             enrichEvent(event, game);
+             startForfeitTimerIfNeeded(event, game);
+             broadcastResult(event, game, roundBefore);
+         }
+     }
+ 
+     /**
+      * Cancels the forfeit timer if the event is a successful reconnection.
+      *
+      * @param event the event that was just successfully applied.
+      */
+     private void cancelForfeitTimerIfReconnect(NetworkEvent event) {
+         if (event.getEventType() == EventType.RECONNECT_PLAYER
+                 && disconnectionTimer != null
+                 && !disconnectionTimer.isDone()) {
+             disconnectionTimer.cancel(false);
+             disconnectionTimer = null;
+         }
+     }
+ 
+     /**
+      * Populates the event with the current game state so that clients can
+      * update their mini-model after receiving it.
+      *
+      * <p>Each event subclass overrides {@link NetworkEvent#enrichWithGameState}
+      * to append any type-specific extra fields (available totems, etc.).
+      *
+      * @param event the event to enrich.
+      * @param game  the current game model.
+      */
+     private void enrichEvent(NetworkEvent event, Game game) {
+         event.enrichWithGameState(game, buildDisconnectedList(game));
+     }
+ 
+     /**
+      * Schedules the 60-second forfeit timer if a disconnection has left
+      * exactly one player online.
+      *
+      * <p>If a previous timer is still pending it is cancelled first to avoid
+      * duplicate timers.
+      *
+      * @param event the event that was just applied.
+      * @param game  the current game model.
+      */
+     private void startForfeitTimerIfNeeded(NetworkEvent event, Game game) {
+         if (event.getEventType() != EventType.DISCONNECTED_PLAYER) return;
+         if (game.getCurrentState().getGameStage() == GameStages.ENDED) return;
+         if (onlinePlayerCount() != 1) return;
+ 
+         if (disconnectionTimer != null && !disconnectionTimer.isDone()) {
+             disconnectionTimer.cancel(false);
+         }
+ 
+         disconnectionTimer = timerExecutor.schedule(
+                 () -> endGameForfeit(game),
+                 1, TimeUnit.MINUTES
+         );
+     }
+ 
+     /**
+      * Ends the game by forfeit when the timer expires without a reconnection.
+      * Broadcasts an {@link EndedGame} event, deletes the save, and resets state.
+      *
+      * @param game the game model captured when the timer was scheduled.
+      */
+     private void endGameForfeit(Game game) {
+         synchronized (gameController) {
+             gameController.endGameForfeit();
+             EndedGame forfeitEnd = new EndedGame(
+                     game.getSlotMap(), game.getOrderLogicCard(),
+                     game.getCurrentState(), game.getPlayerStanding()
+             );
+             broadcaster.notifyAll(forfeitEnd);
+             System.out.println("Timer expired: no player reconnected in 60 s.");
+             removeOfflinePlayers();
+             if (!saveManager.delete()) {
+                 System.out.println("\n!!! Couldn't delete save !!!\n");
+             }
+             disconnectionTimer = null;
+         }
+     }
+ 
+     /**
+      * Determines what to broadcast after a successful event application:
+      * <ul>
+      *   <li>If the round advanced, an {@link ApplyNextRound} event (with updated
+      *       card lists) replaces the original event.</li>
+      *   <li>If the game has ended, an {@link EndedGame} event is sent and the
+      *       save file is deleted.</li>
+      *   <li>Otherwise the original event is broadcast as-is.</li>
+      * </ul>
+      *
+      * @param event       the event that was applied.
+      * @param game        the current game model (post-apply).
+      * @param roundBefore the round number before the event was applied.
+      */
+     private void broadcastResult(NetworkEvent event, Game game, int roundBefore) {
+         broadcaster.notifyAll(event);
+         if (game.getCurrentState().getRound() != roundBefore) {
+             ApplyNextRound nextRound = new ApplyNextRound(
+                     game.getSlotMap(), game.getOrderLogicCard(), game.getCurrentState(),
+                     game.getPlayers(),
+                     game.getUpperListTribeCards(), game.getLowerListTribeCards(),
+                     game.getUpperListBuilding(),   game.getLowerListBuilding()
+             );
+             broadcaster.notifyAll(nextRound);
+         } else if (game.getCurrentState().getGameStage() == GameStages.ENDED) {
+             EndedGame endedGame = new EndedGame(
+                     game.getSlotMap(), game.getOrderLogicCard(),
+                     game.getCurrentState(), game.getPlayerStanding()
+             );
+             broadcaster.notifyAll(endedGame);
+             if (!saveManager.delete()) {
+                 System.out.println("\n!!! Couldn't delete save !!!\n");
+             }
+             removeOfflinePlayers();
+         }
+     }
+ 
+     // ── Utilities ─────────────────────────────────────────────────────────────
+ 
+     /**
+      * Returns the number of players currently marked as online in the player list.
+      */
+     private long onlinePlayerCount() {
+         return playerList.values().stream().filter(v -> v).count();
+     }
+ 
+     /**
+      * Builds the list of usernames of players currently marked as disconnected
+      * in the game model.
+      *
+      * @param game the current game model.
+      * @return a new {@link ArrayList} of disconnected usernames.
+      */
+     private ArrayList<String> buildDisconnectedList(Game game) {
+         return game.getDisconnectedPlayers().entrySet().stream()
+                 .filter(Map.Entry::getValue)
+                 .map(e -> e.getKey().getUserName())
+                 .collect(Collectors.toCollection(ArrayList::new));
+     }
+ 
+     /**
+      * Removes all offline entries (value {@code false}) from the player list.
+      * Online players remain until they disconnect naturally.
+      */
+     private void removeOfflinePlayers() {
+         List<String> toRemove = playerList.entrySet().stream()
+                 .filter(e -> !e.getValue())
+                 .map(Map.Entry::getKey)
+                 .toList();
+         toRemove.forEach(playerList::remove);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-5.html new file mode 100644 index 0000000..453f922 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-5.html @@ -0,0 +1,236 @@ + + + + + + + + Coverage Report > LimitedMap + + + + + + +
+ + +

Coverage Summary for Class: LimitedMap (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
LimitedMap + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/10) + + + + 0% + + + (0/28) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import java.util.Collection;
+ import java.util.Map;
+ import java.util.Set;
+ import java.util.concurrent.ConcurrentHashMap;
+ 
+ /**
+  * A {@link ConcurrentHashMap}-backed map with a configurable size limit and an associated action.
+  * When the number of elements reaches or exceeds the limit, the specified action is automatically triggered.
+  * This implementation is thread-safe for {@code put}; callers that need compound operations must synchronize externally.
+  *
+  * @param <K> the type of keys maintained by this map.
+  * @param <V> the type of mapped values.
+  */
+ public class LimitedMap<K, V> implements Map<K, V> {
+ 
+     private final ConcurrentHashMap<K, V> map = new ConcurrentHashMap<>();
+ 
+     /**
+      * The maximum number of elements allowed in the map before the action is triggered.
+      */
+     private volatile int limit;
+ 
+     /**
+      * The action to execute when the map size reaches or exceeds the limit.
+      */
+     private volatile Runnable action;
+ 
+     /**
+      * Creates a new {@code LimitedMap} with the specified limit and action.
+      *
+      * @param limit  the maximum number of elements before the action is triggered.
+      * @param action the action to execute when the limit is reached.
+      */
+     public LimitedMap(int limit, Runnable action) {
+         this.limit = limit;
+         this.action = action;
+     }
+ 
+     /**
+      * Associates the specified value with the specified key in this map.
+      * If the map size reaches or exceeds the limit after the insertion, the configured action is triggered.
+      *
+      * @param key   the key with which the specified value is to be associated.
+      * @param value the value to be associated with the specified key.
+      * @return the previous value associated with the key, or {@code null} if there was no mapping.
+      */
+     @Override
+     public synchronized V put(K key, V value) {
+         boolean added = true;
+         if (map.size() == limit) {
+             if (!map.containsKey(key))
+                 return null;
+             added = false;
+         }
+         V result = map.put(key, value);
+         if (map.size() >= limit && added) {
+             action.run();
+         }
+         return result;
+     }
+ 
+     @Override
+     public synchronized V remove(Object key) { return map.remove(key); }
+ 
+     @Override
+     public V get(Object key) { return map.get(key); }
+ 
+     @Override
+     public boolean containsKey(Object key) { return map.containsKey(key); }
+ 
+     @Override
+     public boolean containsValue(Object value) { return map.containsValue(value); }
+ 
+     @Override
+     public int size() { return map.size(); }
+ 
+     @Override
+     public boolean isEmpty() { return map.isEmpty(); }
+ 
+     @Override
+     public void putAll(Map<? extends K, ? extends V> m) { m.forEach(this::put); }
+ 
+     @Override
+     public void clear() { map.clear(); }
+ 
+     @Override
+     public Set<K> keySet() { return map.keySet(); }
+ 
+     @Override
+     public Collection<V> values() { return map.values(); }
+ 
+     @Override
+     public Set<Entry<K, V>> entrySet() { return map.entrySet(); }
+ 
+     /**
+      * Sets a new size limit for this map.
+      *
+      * @param num the new limit.
+      */
+     public void setLimit(int num) { this.limit = num; }
+ 
+     /**
+      * Returns the current size limit of this map.
+      *
+      * @return the current limit.
+      */
+     public int getLimit() { return limit; }
+ 
+     /**
+      * Sets a new action to execute when the map size reaches or exceeds the limit.
+      *
+      * @param action the new action to set; must not be {@code null}.
+      */
+     public void setAction(Runnable action) {
+         if (action == null) throw new IllegalArgumentException("action must not be null");
+         this.action = action;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-6.html new file mode 100644 index 0000000..32bc5e2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-6.html @@ -0,0 +1,216 @@ + + + + + + + + Coverage Report > SaveManager + + + + + + +
+ + +

Coverage Summary for Class: SaveManager (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
SaveManager + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/23) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import it.polimi.ingsw.gc14.Model.Game;
+ 
+ import java.io.BufferedInputStream;
+ import java.io.BufferedOutputStream;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
+ import java.io.FileOutputStream;
+ import java.io.IOException;
+ import java.io.ObjectInputStream;
+ import java.io.ObjectOutputStream;
+ import java.net.URISyntaxException;
+ import java.nio.file.Files;
+ import java.nio.file.Path;
+ import java.nio.file.Paths;
+ 
+ /**
+  * Handles persistence of the game model to and from disk.
+  *
+  * <p>The save file is stored at {@code GameSaves/save.dat} relative to the
+  * directory containing the running JAR. The anchor class passed to the
+  * constructor is used to resolve that directory at construction time.
+  *
+  * <p>All three operations ({@link #save}, {@link #load}, {@link #delete})
+  * are independent and safe to call in any order; missing files are treated
+  * as a normal condition (no save present) rather than an error.
+  */
+ public class SaveManager {
+ 
+     /** Relative sub-path of the save file inside the JAR directory. */
+     private static final String SAVE_RELATIVE_PATH = "GameSaves/save.dat";
+ 
+     /** Absolute path of the save file, resolved once at construction. */
+     private final Path filePath;
+ 
+     /**
+      * Constructs a {@code SaveManager} whose save file is located relative
+      * to the JAR directory of the given anchor class.
+      *
+      * @param anchorClass the class whose code-source location is used as
+      *                    the base directory for the save file.
+      * @throws RuntimeException if the JAR path cannot be resolved.
+      */
+     public SaveManager(Class<?> anchorClass) {
+         try {
+             Path jarDir = Paths.get(
+                     anchorClass.getProtectionDomain().getCodeSource().getLocation().toURI()
+             ).getParent();
+             this.filePath = jarDir.resolve(SAVE_RELATIVE_PATH);
+         } catch (URISyntaxException e) {
+             throw new RuntimeException("Could not resolve save file path", e);
+         }
+     }
+ 
+     /**
+      * Serializes the game model to disk, creating parent directories if needed.
+      *
+      * @param game the game model to persist.
+      * @return {@code true} if the save succeeded, {@code false} on I/O error.
+      */
+     public boolean save(Game game) {
+         try {
+             Files.createDirectories(filePath.getParent());
+             try (ObjectOutputStream oos = new ObjectOutputStream(
+                     new BufferedOutputStream(new FileOutputStream(filePath.toFile())))) {
+                 oos.writeObject(game);
+                 System.out.println("Game saved to: " + filePath.toAbsolutePath());
+                 return true;
+             }
+         } catch (IOException e) {
+             e.printStackTrace();
+             return false;
+         }
+     }
+ 
+     /**
+      * Deserializes the game model from disk.
+      *
+      * @return the saved {@link Game} instance, or {@code null} if no save file
+      *         exists or an I/O error prevents reading.
+      * @throws RuntimeException if the serialized class cannot be found on
+      *                          the classpath (indicates a deployment mismatch).
+      */
+     public Game load() {
+         try (ObjectInputStream ois = new ObjectInputStream(
+                 new BufferedInputStream(new FileInputStream(filePath.toFile())))) {
+             return (Game) ois.readObject();
+         } catch (FileNotFoundException e) {
+             return null;
+         } catch (IOException e) {
+             e.printStackTrace();
+             return null;
+         } catch (ClassNotFoundException e) {
+             throw new RuntimeException("Save file references an unknown class", e);
+         }
+     }
+ 
+     /**
+      * Deletes the save file.
+      *
+      * @return {@code true} if the file was deleted, {@code false} otherwise
+      *         (including when the file did not exist).
+      */
+     public boolean delete() {
+         try {
+             return Files.deleteIfExists(filePath);
+         } catch (IOException e) {
+             return false;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-1/sources/source-7.html b/deliverables/Coverage/htmlReport/ns-1/sources/source-7.html new file mode 100644 index 0000000..42d562d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-1/sources/source-7.html @@ -0,0 +1,340 @@ + + + + + + + + Coverage Report > ServerLauncher + + + + + + +
+ + +

Coverage Summary for Class: ServerLauncher (it.polimi.ingsw.gc14)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ServerLauncher + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/24) + + + + 0% + + + (0/72) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Network.CompositeClientBroadcaster;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
+ 
+ import java.net.*;
+ import java.rmi.RemoteException;
+ import java.util.*;
+ import java.util.concurrent.*;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * Main server entry point.
+  *
+  * <p>Responsibilities of this class are intentionally limited to wiring:
+  * it creates all components, connects them together, restores a previously
+  * saved game if one exists, and starts the event-processing loop and the
+  * network servers.
+  *
+  * <p>All game-logic and event-routing decisions are delegated to
+  * {@link GameEventProcessor}; persistence is delegated to {@link SaveManager}.
+  *
+  * <p>The original {@code ServerLauncher} class is preserved and untouched.
+  * This class is a clean replacement that uses the new component structure.
+  */
+ public class ServerLauncher {
+ 
+     /** Drives the main game-event loop. */
+     private final GameEventProcessor eventProcessor;
+ 
+     /**
+      * Constructs a {@code ServerLauncherTest} and wires all components together.
+      *
+      * @param actionQueue    the shared event queue.
+      * @param gameController the server-side game controller.
+      * @param playerList     the shared player-status map.
+      * @param broadcaster    the broadcaster used to reach all connected clients.
+      * @param saveManager    the save manager used to persist game state.
+      */
+     public ServerLauncher(
+             BlockingQueue<NetworkEvent> actionQueue,
+             GameController gameController,
+             LimitedMap<String, Boolean> playerList,
+             CompositeClientBroadcaster broadcaster,
+             SaveManager saveManager) {
+         this.eventProcessor = new GameEventProcessor(
+                 actionQueue, gameController, playerList, broadcaster, saveManager);
+     }
+ 
+     // ── Entry point ───────────────────────────────────────────────────────────
+ 
+     /**
+      * Initialises all server components, wires them together, restores a saved
+      * game if available, and starts the event-processing loop and both network
+      * servers.
+      *
+      * @param args command-line arguments (unused).
+      * @throws RemoteException if the RMI server cannot be created.
+      */
+     public static void main(String[] args) throws RemoteException {
+         LimitedMap<String, Boolean> playerList  = new LimitedMap<>(5, () -> {});
+         BlockingQueue<NetworkEvent>  actionQueue = new LinkedBlockingQueue<>();
+         GameController               gameController = new GameController();
+ 
+         String ip;
+         try {
+             ip = chooseNetworkInterface(new Scanner(System.in));
+             System.out.println(ip);
+         } catch (Exception e) {
+             throw new RuntimeException(e);
+         }
+         System.setProperty("java.rmi.server.hostname", ip);
+ 
+         RMIServer        rmiServer   = new RMIServer(gameController, NetworkConfig.RMI_PORT, actionQueue, playerList, ip);
+         TCPServer        tcpServer   = new TCPServer(gameController, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT, actionQueue, playerList);
+         CompositeClientBroadcaster broadcaster = new CompositeClientBroadcaster(rmiServer, tcpServer);
+         SaveManager       saveManager = new SaveManager(ServerLauncher.class);
+ 
+         restoreGameIfSaved(gameController, playerList, saveManager);
+ 
+         ServerLauncher launcher = new ServerLauncher(
+                 actionQueue, gameController, playerList, broadcaster, saveManager);
+ 
+         // When all required players have joined, broadcast the initial MiniModel.
+         playerList.setAction(() -> new Thread(() -> {
+             MiniModel miniModel;
+             synchronized (gameController) {
+                 Game game = gameController.getModel();
+                 miniModel = new MiniModel(
+                         game.getSlotMap(), game.getOrderLogicCard(), game.getCurrentState(),
+                         game.getPlayers(), game.getAvailableTotems(),
+                         game.getUpperListTribeCards(), game.getLowerListTribeCards(),
+                         game.getUpperListBuilding(),   game.getLowerListBuilding(),
+                         game.getDisconnectedPlayers().entrySet().stream()
+                                 .filter(Map.Entry::getValue)
+                                 .map(e -> e.getKey().getUserName())
+                                 .collect(Collectors.toCollection(ArrayList::new))
+                 );
+             }
+             broadcaster.notifyAll(miniModel);
+         }).start());
+ 
+         new Thread(() -> {
+             try { launcher.run(); }
+             catch (Exception e) {
+                 System.out.println("Unexpected exception in game loop");
+                 e.printStackTrace();
+             }
+         }).start();
+ 
+         rmiServer.start();
+         new Thread(() -> tcpServer.start()).start();
+         System.out.println("Server RMI: " + System.getProperty("java.rmi.server.hostname"));
+     }
+ 
+     // ── Game loop ─────────────────────────────────────────────────────────────
+ 
+     /**
+      * Runs the event-processing loop until the thread is interrupted.
+      *
+      * <p>A {@link ConcurrentModificationException} is caught and logged rather
+      */
+     public void run() {
+         while (true) {
+             try {
+                 eventProcessor.doFirstEvent();
+             } catch (InterruptedException e) {
+                 Thread.currentThread().interrupt();
+                 break;
+             }
+         }
+     }
+ 
+     // ── Crash recovery ────────────────────────────────────────────────────────
+ 
+     /**
+      * Attempts to restore a previously saved game.
+      *
+      * <p>The save is discarded if all but at most one player was offline at the
+      * time of the crash, since there would be nobody to resume the game with.
+      * Otherwise the model is restored, the player-list limit is set, and each
+      * player who was offline at crash time is pre-populated as offline so the
+      * reconnection flow can handle them correctly.
+      *
+      * @param gameController the controller that will receive the restored model.
+      * @param playerList     the player-status map to populate.
+      * @param saveManager    the save manager to load from.
+      */
+     private static void restoreGameIfSaved(
+             GameController gameController,
+             LimitedMap<String, Boolean> playerList,
+             SaveManager saveManager) {
+ 
+         Game game = saveManager.load();
+         if (game == null) return;
+ 
+         long disconnectedCount = game.getDisconnectedPlayers().entrySet().stream()
+                 .filter(Map.Entry::getValue).count();
+ 
+         if (disconnectedCount >= game.getNPlayers() - 1) {
+             saveManager.delete();
+             System.out.println("Save discarded: too many players were offline at crash time.");
+             return;
+         }
+ 
+         gameController.setModel(game);
+         playerList.setLimit(game.getNPlayers());
+ 
+         for (Map.Entry<Player, Boolean> entry : game.getDisconnectedPlayers().entrySet()) {
+             if (entry.getValue()) {
+                 playerList.put(entry.getKey().getUserName(), false);
+             }
+         }
+         System.out.println("Game restored from save (" + game.getNPlayers() + " players).");
+     }
+ 
+     // ── Network interface selection ───────────────────────────────────────────
+ 
+     /**
+      * Lists active non-loopback IPv4 network interfaces and prompts the operator
+      * to choose one. If only one interface is available it is selected automatically.
+      *
+      * @param scanner the scanner used to read the operator's choice.
+      * @return the IPv4 address of the selected interface.
+      * @throws Exception if no valid network interface is available.
+      */
+     public static String chooseNetworkInterface(Scanner scanner) throws Exception {
+         List<String> ips = new ArrayList<>();
+ 
+         Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+         while (interfaces.hasMoreElements()) {
+             NetworkInterface ni = interfaces.nextElement();
+             if (!ni.isUp() || ni.isLoopback() || ni.isVirtual()) continue;
+ 
+             Enumeration<InetAddress> addresses = ni.getInetAddresses();
+             while (addresses.hasMoreElements()) {
+                 InetAddress addr = addresses.nextElement();
+                 if (addr instanceof Inet4Address) {
+                     System.out.println("[" + ips.size() + "] " + ni.getDisplayName()
+                             + " -> " + addr.getHostAddress());
+                     ips.add(addr.getHostAddress());
+                 }
+             }
+         }
+ 
+         if (ips.isEmpty()) throw new Exception("No active network interface available");
+ 
+         if (ips.size() == 1) {
+             System.out.println("One interface found, using: " + ips.get(0));
+             return ips.get(0);
+         }
+ 
+         System.out.print("Choose interface: ");
+         int choice = Integer.parseInt(scanner.nextLine().trim());
+         return ips.get(choice);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index.html b/deliverables/Coverage/htmlReport/ns-10/index.html new file mode 100644 index 0000000..49cbb56 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..a4dee60 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..4442931 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..df5c91d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..b5c5fdd --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE.html new file mode 100644 index 0000000..ef31f5e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..74dd8b3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..f827250 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..57659d3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..df71b79 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,167 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Client + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-10/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-10/sources/source-1.html new file mode 100644 index 0000000..e166537 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-10/sources/source-1.html @@ -0,0 +1,429 @@ + + + + + + + + Coverage Report > TCPClient + + + + + + +
+ + +

Coverage Summary for Class: TCPClient (it.polimi.ingsw.gc14.Network.TCP.Client)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/26) + + + + 0% + + + (0/83) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.TCP.Client;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.IClient;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
+ 
+ import java.io.*;
+ import java.net.*;
+ import java.util.concurrent.Executors;
+ import java.util.concurrent.ScheduledExecutorService;
+ import java.util.concurrent.TimeUnit;
+ 
+ /**
+  * Client TCP. Sends and receives messages with the TCP server.
+  */
+ public class TCPClient implements IClient {
+     private static final int PING = 1;
+     private static final int PONG = 2;
+ 
+     /** Socket TCP */
+     private Socket communicationSocket;
+ 
+     /** Input stream used receive objects from the server */
+     private ObjectInputStream socketReceive;
+ 
+     /** Output stream used to send objects to the server */
+     private ObjectOutputStream socketSend;
+ 
+     /** Client game's controller */
+     private ClientController controller;
+ 
+     /** IP address of the server to connect to */
+     private String hostname;
+ 
+     private boolean running;
+     /** TCP port */
+     private int mainPort;
+ 
+     private int heartbeatPort;
+     private Socket heartbeatSocket;
+     private OutputStream heartbeatOut;
+     private InputStream heartbeatIn;
+ 
+ 
+     /**
+      * Constructs a TCP client and initializes its connection parameters.
+      *
+      * @param controller    the client controller.
+      * @param hostname      the IP address or hostname of the server.
+      * @param mainPort      the main TCP port of the server.
+      * @param heartbeatPort the TCP port used for heartbeat communication.
+      */
+     public TCPClient(ClientController controller, String hostname, int mainPort,int heartbeatPort ) {
+         this.controller = controller;
+         this.hostname = hostname;
+         this.mainPort = mainPort;
+         this.heartbeatPort = heartbeatPort;
+     }
+ 
+ 
+     /**
+      * Starts the TCP connection with the server.
+      * Sends an {@link AddPlayer} event, if the server responds with {@code -1}, the connection is refused and the method returns {@code false}.
+      * Otherwise, a listener thread is started.
+      * @param user             The username of the player
+      * @param proposedNPlayers The desired number of players for the game
+      * @return true if the connection is successful, false otherwise.
+      */
+     public ErrorType connect(String user, int proposedNPlayers) {
+         try {
+             communicationSocket = new Socket(hostname, mainPort);
+             socketSend    = new ObjectOutputStream(communicationSocket.getOutputStream());
+             socketReceive = new ObjectInputStream(communicationSocket.getInputStream());
+             NetworkEvent event= new AddPlayer(user, proposedNPlayers);
+             socketSend.writeObject(event);
+             try {
+                 if( socketReceive.readObject() instanceof AddPlayer x)
+                 {
+                     if(x.isError())
+                         return x.getErrorType();
+                 }
+             } catch (ClassNotFoundException e) {
+                 return ErrorType.GENERIC_ERROR;
+             }
+ 
+             running = true;
+ 
+             new Thread(this::receiveMessage, "tcp-reader").start();
+ 
+             // heartbeat socket
+             this.heartbeatSocket = new Socket(hostname, heartbeatPort);
+             this.heartbeatOut = heartbeatSocket.getOutputStream();
+             this.heartbeatIn  = heartbeatSocket.getInputStream();
+ 
+             // send username immediately so server can associate the two sockets
+             new ObjectOutputStream(heartbeatSocket.getOutputStream()).writeObject(user);
+             heartbeatOut.flush();
+             new Thread(this::heartbeatLoop, "heartbeat").start();
+ 
+             return null;
+ 
+         } catch (IOException e) {
+             e.printStackTrace();
+             return ErrorType.GENERIC_ERROR;
+         }
+     }
+ 
+     private void heartbeatLoop() {
+         ScheduledExecutorService sender = Executors.newSingleThreadScheduledExecutor();
+         sender.scheduleAtFixedRate(() -> {
+             try {
+                 synchronized (heartbeatOut)
+                 {
+                     heartbeatOut.write(PING);
+                     heartbeatOut.flush();
+                 }
+ 
+             } catch (IOException e) {
+                 sender.shutdownNow();
+                 if(running)
+                 {
+                     disconnect();
+                     controller.getView().showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
+                 }
+ 
+             }
+         }, 0, 3, TimeUnit.SECONDS);
+ 
+         try {
+             heartbeatSocket.setSoTimeout((int) NetworkConfig.SILENCE_THRESHOLD_MS);
+             while (running) {
+                 int b = heartbeatIn.read();
+                 if (b == -1 || b != PONG) {
+                     disconnect();
+                     controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString());
+                     break;
+                 }
+                 // pong received: server is alive
+             }
+         } catch (SocketTimeoutException e) {
+             System.out.println("Server heartbeat timeout");
+             disconnect();
+             controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString());
+         } catch (IOException e) {
+             if (running) {
+                 disconnect();
+                 controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString());
+             }
+         } finally {
+             sender.shutdownNow();
+         }
+     }
+     private synchronized void disconnect() {
+         if (!running) return;
+         running = false;
+         try { communicationSocket.close(); } catch (IOException ignored) {}
+         try { heartbeatSocket.close();     } catch (IOException ignored) {}
+         controller.setClient(null);
+         controller.setModel(null);
+     }
+ 
+ 
+     /**
+      * Listens continuously for incoming objects from the server.
+      *   - If the received object is a {@link NetworkEvent} flagged as an error, it is printed.
+      *   - If the received object is a valid {@link NetworkEvent}, it is applied to the game controller.
+      *   - If the received object is a {@link MiniModel}, the controller's model is set.
+      */
+     private void receiveMessage() {
+         while (true) {
+             try {
+                 Object read;
+                 try {
+                     read = socketReceive.readObject();
+                 } catch (IOException e) {
+                     if (running) disconnect();
+                     break;
+                 }
+ 
+                 if (read instanceof NetworkEvent event) {
+                     if (event.isError()) {
+                         if(event.getErrorType() == ErrorType.WRONG_ACTION) {
+                             controller.getView().showError(ErrorType.WRONG_ACTION,event.toString());
+                         }
+                         else
+                             controller.getView().showError(event.getErrorType(),event.getErrorType().toString());
+                     } else {
+                         event.apply(controller.getMiniModel());
+                         controller.getView().render();
+                     }
+ 
+                 } else if (read instanceof MiniModel model) {
+                     controller.setModel(model);
+                     controller.getView().render();
+                 }
+ 
+             } catch (ClassNotFoundException e) {
+                 e.printStackTrace();
+                 break;
+             }
+         }
+     }
+ 
+     /**
+      * Requests to draw a tribe card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperTribeCard(String playerUsername, int pos) {
+         doEvent(new DrawUpperTribeCard(playerUsername,pos));
+ 
+     }
+ 
+ 
+     /**
+      * Requests to draw a tribe card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerTribeCard(String playerUsername,int pos) {
+         doEvent(new DrawLowerTribeCard(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperBuildingCard(String playerUsername,int pos) {
+         doEvent(new DrawUpperBuildingCard(playerUsername,pos));
+ 
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerBuildingCard(String playerUsername,int pos) {
+         doEvent(new DrawLowerBuildingCard(playerUsername,pos));
+     }
+ 
+ 
+ 
+     /**
+      * Requests to skip drawing turn.
+      * This action is available only when  the player cannot draw any tribe card, but still can buy some buildings.
+      * @param playerUsername the name of the player performing the action
+      */
+     public void skipTurn(String playerUsername) {
+         doEvent(new SkipTurn(playerUsername));
+     }
+ 
+ 
+     /**
+      * Used to perform the slot choice action for the specified player at the specified position.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the selected slot
+      */
+     public void slotChoice(String playerUsername,int pos) {
+         doEvent(new SlotChoice(playerUsername,pos));
+     }
+     /**
+      * Sends a {@link NetworkEvent} to the server.
+      * @param event The NetworkEvent to send.
+      */
+     private void doEvent(NetworkEvent event) {
+         try {
+             synchronized (socketSend) {
+                 socketSend.writeObject(event);
+             }
+         } catch (IOException e) {
+             e.printStackTrace();
+         }
+     }
+ 
+     /**
+      * Sends a totem choice event to the server for the specified player.
+      *
+      * @param playerUsername the username of the player choosing the totem.
+      * @param totems the name of the chosen totem.
+      */
+     public void totemChoice(String playerUsername,String totems) {
+         doEvent(new TotemChoice(playerUsername,totems));
+     }
+ 
+     /**
+      * Notifies the server of a voluntary disconnection by sending a sentinel value
+      * on the heartbeat channel, then closes the connection.
+      */
+     public void notifyDisconnection()
+     {
+         synchronized (heartbeatOut)
+         {
+             try {
+                 heartbeatOut.write(-1);
+             } catch (IOException e) {
+                 disconnect();
+             }
+         }
+         disconnect();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index.html b/deliverables/Coverage/htmlReport/ns-11/index.html new file mode 100644 index 0000000..66b1790 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..c802910 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..43a0b4a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..b1326d3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..4b3dc5b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE.html new file mode 100644 index 0000000..ed8485c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..faac8f3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..6fa987d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..67d2f65 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..a15292f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,237 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.TCP.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.TCP.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.TCP.Server + + 0% + + + (0/3) + + + + 0% + + + (0/19) + + + + 0% + + + (0/50) + + + + 0% + + + (0/166) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-11/sources/source-1.html new file mode 100644 index 0000000..4feb039 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/sources/source-1.html @@ -0,0 +1,267 @@ + + + + + + + + Coverage Report > ClientHandler + + + + + + +
+ + +

Coverage Summary for Class: ClientHandler (it.polimi.ingsw.gc14.Network.TCP.Server)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientHandler + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/14) + + + + 0% + + + (0/32) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.TCP.Server;
+ 
+ import it.polimi.ingsw.gc14.LimitedMap;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer;
+ 
+ import java.io.*;
+ import java.net.*;
+ import java.util.List;
+ import java.util.concurrent.BlockingQueue;
+ 
+ /**
+  * Handles the TCP connection with a single client.
+  * Each instance runs on a dedicated thread and is responsible for receiving {@link NetworkEvent} from its client and adding them
+  * to the {@link #actionQueue}.
+  * It is also responsible to send events and game model updates back to the client.
+  */
+ public class ClientHandler implements Runnable {
+     /**
+      * The username of the connected client on this handler
+      */
+     private final String username;
+ 
+     private volatile boolean running;
+ 
+     /**
+      * Returns the username associated with this client.
+      *
+      * @return the username associated with this client.
+      */
+     public String getUsername() {
+         return username;
+     }
+     /** The TCP socket */
+     private Socket clientSocket;
+ 
+     /** Input stream used to receive objects from the client */
+     private ObjectInputStream in;
+ 
+     /** Output stream used to send objects to the client */
+     private ObjectOutputStream out;
+ 
+     /**
+      * Shared list of all client handlers.
+      * This handler removes itself from the list when disconnected.
+      */
+     private List<ClientHandler> clientHandlers;
+ 
+     /** Maps each connected player's username to their connection state (true = connected). */
+     private LimitedMap<String, Boolean> limitedMap;
+ 
+     /** Queue containing the events to be applied to the game model */
+     private BlockingQueue<NetworkEvent> actionQueue;
+ 
+ 
+     /**
+      * Class constructor that initializes the attributes.
+      *
+      * @param username       the username associated with the client.
+      * @param clientSocket   the socket representing the client's TCP connection.
+      * @param out            the output stream used to send data to the client.
+      * @param in             the input stream used to receive data from the client.
+      * @param clientHandlers the shared list of all active client handlers.
+      * @param playersMap     the shared map containing the connected players.
+      * @param actionQueue    the queue containing incoming events.
+      */
+     public ClientHandler(String username, Socket clientSocket, ObjectOutputStream out, ObjectInputStream in, List<ClientHandler> clientHandlers, LimitedMap<String,Boolean> playersMap, BlockingQueue<NetworkEvent> actionQueue) {
+         this.username=username;
+         this.clientSocket = clientSocket;
+         this.in = in;
+         this.out = out;
+         this.clientHandlers = clientHandlers;
+         this.actionQueue = actionQueue;
+         this.limitedMap = playersMap;
+     }
+ 
+ 
+     /**
+      * Listens for incoming {@link NetworkEvent}s from the client and adds them to the {@link #actionQueue}.
+      * Upon disconnection, this handler removes itself from {@link #clientHandlers}.
+      */
+     @Override
+     public void run() {
+         running = true;
+         try {
+             while (running) {
+                 NetworkEvent event = (NetworkEvent) in.readObject();
+                 if (!actionQueue.offer(event)) {
+                     System.out.println("Error inserting action into queue");
+                 }
+             }
+         } catch (IOException e) {
+             System.err.println("Error in incoming connection/disconnection: " + username);
+         } catch (ClassNotFoundException e) {
+             System.err.println("Class not found: " + username);
+         } finally {
+             if (running) disconnect();
+         }
+     }
+ 
+ 
+ 
+     /**
+      * Sends a {@link NetworkEvent} to the client.
+      * @param event The network event to send to the client.
+      */
+     public synchronized void notifyEvent(NetworkEvent event) {
+         try {
+             out.reset();
+             out.writeObject(event);
+         } catch (IOException e) {
+             e.printStackTrace();
+             disconnect();
+         }
+ 
+     }
+ 
+ 
+     /**
+      * Sends the current game model to this client.
+      * @param game The current state of the game to send to the client.
+      */
+     public synchronized void notifyMiniModel(MiniModel game) {
+         try {
+             out.reset();
+             out.writeObject(game);
+         } catch (IOException e) {
+             e.printStackTrace();
+             disconnect();
+         }
+     }
+ 
+     /**
+      * Disconnects the client from the server.
+      *
+      * <p>The client handler is stopped and removed from the list of active handlers.
+      * The player is marked as disconnected, a {@link DisconnectedPlayer} event is
+      * added to the action queue, and the associated socket is closed.
+      */
+     public synchronized void disconnect() {
+         if (!running) return;
+         running = false;
+         clientHandlers.remove(this);
+         limitedMap.put(username, false);
+         actionQueue.add(new DisconnectedPlayer(username));
+         System.out.println("Disconnected player: " + username);
+         try { clientSocket.close(); } catch (IOException ignored) {}
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-11/sources/source-2.html new file mode 100644 index 0000000..5e540fd --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/sources/source-2.html @@ -0,0 +1,247 @@ + + + + + + + + Coverage Report > HeartbeatHandler + + + + + + +
+ + +

Coverage Summary for Class: HeartbeatHandler (it.polimi.ingsw.gc14.Network.TCP.Server)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
HeartbeatHandler + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/8) + + + + 0% + + + (0/29) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.TCP.Server;
+ 
+ import java.io.*;
+ import java.net.*;
+ import java.util.concurrent.Executors;
+ import java.util.concurrent.ScheduledExecutorService;
+ import java.util.concurrent.TimeUnit;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ 
+ /**
+  * Handles the heartbeat communication associated with a TCP client.
+  *
+  * <p>This component listens for heartbeat {@code PING} messages from the client,
+  * replies with {@code PONG} messages, and periodically checks whether the client
+  * has remained silent for too long. If a timeout or communication error occurs,
+  * both the heartbeat connection and the main client connection are disconnected.
+  */
+ public class HeartbeatHandler implements Runnable {
+ 
+     private final String username;
+     private final Socket socket;
+     private final InputStream in;
+     private final OutputStream out;
+ 
+     /**
+      * Byte value representing a heartbeat ping message.
+      */
+     private static final int PING = 1;
+ 
+     /**
+      * Byte value representing a heartbeat pong response.
+      */
+     private static final int PONG = 2;
+ 
+     /**
+      * Main client handler associated with this heartbeat connection.
+      */
+     private final ClientHandler mainHandler;
+ 
+     /**
+      * Timestamp of the last received heartbeat message.
+      */
+     private volatile long lastReceivedTime = System.currentTimeMillis();
+ 
+     /**
+      * Indicates whether the heartbeat handler is still active.
+      */
+     private volatile boolean running = true;
+ 
+ 
+     /**
+      * Executor used to periodically check heartbeat timeouts.
+      */
+     private final ScheduledExecutorService watchdog =
+             Executors.newSingleThreadScheduledExecutor();
+ 
+     /**
+      * Constructs a heartbeat handler for the specified client.
+      *
+      * @param username    the username of the connected client.
+      * @param socket      the socket dedicated to heartbeat communication.
+      * @param mainHandler the main client handler associated with the same player.
+      * @throws IOException if the input or output stream cannot be obtained from the socket.
+      */
+     public HeartbeatHandler(String username, Socket socket, ClientHandler mainHandler)
+             throws IOException {
+         this.username = username;
+         this.socket = socket;
+         this.mainHandler = mainHandler;
+         this.in = socket.getInputStream();
+         this.out = socket.getOutputStream();
+     }
+ 
+     /**
+      * Starts the heartbeat listening loop.
+      *
+      * <p>The method activates the watchdog task, then waits for incoming heartbeat
+      * messages. When a {@code PING} is received, the last-received timestamp is
+      * updated and a {@code PONG} response is sent back to the client.
+      * If the stream is closed or an I/O error occurs, the client is disconnected.
+      */
+     @Override
+     public void run() {
+         startWatchdog();
+         try {
+             while (running) {
+                 int b = in.read(); // blocks until a byte arrives
+                 if (b == -1) {
+                     disconnect();
+                     break; // stream closed
+                 }
+                 if (b == PING) {
+                     lastReceivedTime = System.currentTimeMillis();
+                     out.write(PONG);
+                     out.flush();
+                 }
+             }
+         } catch (IOException e) {
+             disconnect();
+         }
+     }
+ 
+     /**
+      * Starts the periodic watchdog task that detects heartbeat timeouts.
+      *
+      * <p>If no heartbeat message is received within the configured silence threshold,
+      * the associated client is disconnected.
+      */
+     private void startWatchdog() {
+         watchdog.scheduleAtFixedRate(() -> {
+             if (System.currentTimeMillis() - lastReceivedTime > NetworkConfig.SILENCE_THRESHOLD_MS) {
+                 System.out.println("Heartbeat timeout: " + username);
+                 disconnect();
+             }
+         }, 1, 1, TimeUnit.SECONDS);
+     }
+ 
+     /**
+      * Disconnects the heartbeat channel and the associated main client connection.
+      *
+      * <p>The handler is stopped, the watchdog task is terminated, the main
+      * {@link ClientHandler} is disconnected, and the heartbeat socket is closed.
+      */
+     private synchronized void disconnect() {
+         running = false;
+         watchdog.shutdownNow();
+         mainHandler.disconnect(); // disconnette anche il socket principale
+         System.out.println("Disconnected: " + username);
+         try { socket.close(); } catch (IOException ignored) {}
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-11/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-11/sources/source-3.html new file mode 100644 index 0000000..5b356c9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-11/sources/source-3.html @@ -0,0 +1,438 @@ + + + + + + + + Coverage Report > TCPServer + + + + + + +
+ + +

Coverage Summary for Class: TCPServer (it.polimi.ingsw.gc14.Network.TCP.Server)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
TCPServer + + 0% + + + (0/1) + + + + 0% + + + (0/8) + + + + 0% + + + (0/28) + + + + 0% + + + (0/105) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.TCP.Server;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.LimitedMap;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.AddPlayer;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.ReconnectPlayer;
+ 
+ import java.io.*;
+ import java.net.*;
+ import java.util.ArrayList;
+ import java.util.Map;
+ import java.util.concurrent.CopyOnWriteArrayList;
+ import java.util.concurrent.BlockingQueue;
+ import java.util.concurrent.ConcurrentHashMap;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * TCP server responsible for accepting client connections,
+  * handling player registration and reconnection, and sending
+  * game updates to connected clients.
+  *
+  * <p>The server also manages a dedicated heartbeat channel used
+  * to detect disconnected clients and associate each heartbeat
+  * connection with the corresponding {@link ClientHandler}.
+  */
+ public class TCPServer {
+ 
+     /**
+      * Main TCP port used for standard client-server communication.
+      */
+     private int port;
+ 
+     /**
+      * TCP port dedicated to heartbeat communication.
+      */
+     private int heartbeatPort;
+ 
+     /**
+      * Main server socket used to accept client connections.
+      */
+     private ServerSocket socketTCP;
+ 
+     /**
+      * Server socket used to accept heartbeat connections.
+      */
+     private ServerSocket heartbeatSocketTCP;
+ 
+     /**
+      * Game controller used to manage the server-side game logic.
+      */
+     private final GameController controller;
+ 
+     /**
+      * Queue containing network events received from clients.
+      */
+     private BlockingQueue<NetworkEvent> actionQueue;
+ 
+     /**
+      * Map storing the online/offline status of connected players.
+      */
+     private LimitedMap<String, Boolean> playerList;
+ 
+     /**
+      * List of active TCP client handlers.
+      */
+     private CopyOnWriteArrayList<ClientHandler> clientHandlers;
+ 
+ 
+     /**
+      * Temporary map associating each username with the corresponding
+      * {@link ClientHandler} waiting for its heartbeat connection.
+      */
+     private final Map<String, ClientHandler> pendingHeartbeat = new ConcurrentHashMap<>();
+ 
+     /**
+      * Constructs a TCP server with the required game and network components.
+      *
+      * @param controller    the game controller used to manage the game logic.
+      * @param port          the main TCP port used for client communication.
+      * @param heartbeatPort the TCP port dedicated to heartbeat connections.
+      * @param actionQueue   the queue containing incoming network events.
+      * @param playerList    the map storing the connection status of the players.
+      */
+     public TCPServer(GameController controller,
+                      int port,
+                      int heartbeatPort,
+                      BlockingQueue<NetworkEvent> actionQueue,
+                      LimitedMap<String, Boolean> playerList) {
+         this.port = port;
+         this.heartbeatPort = heartbeatPort;
+         this.controller = controller;
+         this.actionQueue = actionQueue;
+         this.playerList = playerList;
+         this.clientHandlers = new CopyOnWriteArrayList<>();
+     }
+ 
+     /**
+      * Starts the TCP server and begins accepting client connections.
+      *
+      * <p>The method opens both the main TCP server socket and the dedicated
+      * heartbeat server socket. It then starts a separate thread for heartbeat
+      * connections and continuously waits for new players or reconnecting clients.
+      *
+      * <p>When a new connection is received, the first event must be an
+      * {@link AddPlayer} request. Depending on the current server state,
+      * the connection is handled either as a new player joining the game
+      * or as a reconnection attempt.
+      *
+      */
+     public void start() {
+         try {
+             socketTCP = new ServerSocket(port);
+             heartbeatSocketTCP = new ServerSocket(heartbeatPort);
+         } catch (IOException e) {
+             System.out.println("Could not start TCP server");
+             e.printStackTrace();
+             return;
+         }
+ 
+         System.out.println("TCP server started on port: " + port);
+         System.out.println("Heartbeat server started on port: " + heartbeatPort);
+ 
+         new Thread(this::acceptHeartbeat, "heartbeat-acceptor").start();
+ 
+         while (true) {
+             try {
+                 Socket clientSocket = socketTCP.accept();
+ 
+                 ObjectOutputStream clientSend = new ObjectOutputStream(clientSocket.getOutputStream());
+                 clientSend.flush();
+                 ObjectInputStream clientReceive = new ObjectInputStream(clientSocket.getInputStream());
+ 
+                 NetworkEvent event = (NetworkEvent) clientReceive.readObject();
+ 
+                 if (!(event.getEventType() == EventType.ADD_PLAYER)) {
+                     clientSocket.close();
+                     System.out.println("Invalid parameters. Connection terminated.");
+                     continue;
+                 }
+ 
+                 AddPlayer eventAddPlayer = (AddPlayer) event;
+ 
+                 if (eventAddPlayer.getProposedNPlayer() < NetworkConfig.MIN_PLAYERS
+                         || eventAddPlayer.getProposedNPlayer() > NetworkConfig.MAX_PLAYERS) {
+                     eventAddPlayer.setErrorType(ErrorType.WRONG_PLAYER_NUMBER);
+                     eventAddPlayer.setIsError(true);
+                     clientSend.writeObject(eventAddPlayer);
+                     clientSocket.close();
+                     System.out.println("Invalid parameters. Connection terminated.");
+                     continue;
+                 }
+ 
+                 synchronized (controller) {
+                     String username = eventAddPlayer.getUsername();
+                     //reconnect players after a server crash
+                     if (playerList.isEmpty()&& controller.getModel()==null) {
+                         Game model = new Game(eventAddPlayer.getProposedNPlayer());
+                         controller.setModel(model);
+                         playerList.setLimit(eventAddPlayer.getProposedNPlayer());
+                         System.out.println("Game Created With :"+eventAddPlayer.getProposedNPlayer()+" Players");
+                     }
+                     if(controller.getModel().getCurrentState().getGameStage()!= GameStages.WAITING ) {
+                         if (controller.getModel().getPlayers().stream().noneMatch(p -> p.getUserName().equals(username))|| controller.getModel().getCurrentState().getGameStage()==GameStages.ENDED) {
+                             eventAddPlayer.setErrorType(ErrorType.GAME_ALREADY_STARTED);
+                             eventAddPlayer.setIsError(true);
+                             clientSend.writeObject(eventAddPlayer);
+                             clientSocket.close();
+                             System.out.println("Invalid parameters. Connection terminated.");
+                             continue;
+                         }
+                     }
+                     else {
+                         if (controller.addPlayer(username)) {
+                             playerList.put(username, true);
+                             System.out.println("Accepted player: " + username);
+                             clientSend.writeObject(eventAddPlayer);
+                             ClientHandler handler = createAndRegisterHandler(
+                                     username, clientSocket, clientSend, clientReceive);
+                             new Thread(handler).start();
+                             continue;
+                         } else {
+                             eventAddPlayer.setErrorType(ErrorType.USERNAME_ALREADY_USED);
+                             eventAddPlayer.setIsError(true);
+                             clientSend.writeObject(eventAddPlayer);
+                             clientSocket.close();
+                             System.out.println("Invalid parameters. Connection terminated.");
+                             continue;
+                         }
+                     }
+ 
+                     if (!playerList.containsKey(username)) {
+                         playerList.put(username, true);
+                         System.out.println("(After crash)Reconnected player: " + username);
+                         clientSend.writeObject(eventAddPlayer);
+                         ClientHandler handler = createAndRegisterHandler(
+                                 username, clientSocket, clientSend, clientReceive);
+                         new Thread(handler).start();
+                     } else if (!playerList.get(username)) {
+                         // reconnect a previously disconnected player
+                         playerList.put(username, true);
+                         System.out.println("Reconnected player: " + username);
+                         clientSend.writeObject(eventAddPlayer);
+                         ClientHandler handler = createAndRegisterHandler(
+                                 username, clientSocket, clientSend, clientReceive);
+                         Game game = controller.getModel();
+                         handler.notifyMiniModel(new MiniModel(
+                                 game.getSlotMap(), game.getOrderLogicCard(),
+                                 game.getCurrentState(), game.getPlayers(),
+                                 game.getAvailableTotems(),
+                                 game.getUpperListTribeCards(), game.getLowerListTribeCards(),
+                                 game.getUpperListBuilding(), game.getLowerListBuilding(),
+                                 disconnectedUsernames(game)));
+                         new Thread(handler).start();
+                         actionQueue.add(new ReconnectPlayer(username));
+                     } else {
+                         eventAddPlayer.setErrorType(ErrorType.USER_ALREADY_CONNECTED);
+                         eventAddPlayer.setIsError(true);
+                         clientSend.writeObject(eventAddPlayer);
+                         clientSocket.close();
+                         System.out.println("Invalid parameters. Connection terminated.");
+                     }
+                 }
+             } catch (IOException | ClassNotFoundException e) {
+                 e.printStackTrace();
+             }
+         }
+     }
+ 
+     /**
+      * Accepts heartbeat connections and associates them with the correct client handler.
+      *
+      * <p>Each client immediately sends its username on the heartbeat channel.
+      * The method uses that username to retrieve the pending {@link ClientHandler}
+      * and starts a dedicated {@link HeartbeatHandler}. If no pending handler is found,
+      * the heartbeat socket is closed.
+      */
+     private void acceptHeartbeat() {
+         while (true) {
+             try {
+                 Socket hbSocket = heartbeatSocketTCP.accept();
+                 ObjectInputStream hbIn =
+                         new ObjectInputStream(hbSocket.getInputStream());
+ 
+                 String username = (String) hbIn.readObject();
+ 
+                 ClientHandler handler = pendingHeartbeat.remove(username);
+ 
+                 if (handler != null) {
+                     HeartbeatHandler hb =
+                             new HeartbeatHandler(username, hbSocket, handler);
+ 
+                     new Thread(hb, "heartbeat-" + username).start();
+                     System.out.println("Heartbeat connected for: " + username);
+                 } else {
+                     System.out.println(
+                             "No pending handler for: " + username + ", closing heartbeat."
+                     );
+                     hbSocket.close();
+                 }
+ 
+             } catch (IOException | ClassNotFoundException e) {
+                 e.printStackTrace();
+             }
+         }
+     }
+ 
+     /**
+      * Notifies connected TCP clients of a new network event.
+      *
+      * <p>If the event does not represent an error, it is sent to all connected clients.
+      * If it represents an error, it is sent only to the client that requested the action.
+      *
+      * @param event the network event to send to the clients.
+      */
+     public void notifyAll(NetworkEvent event) {
+         clientHandlers.forEach(h -> {
+             if (!event.isError() || event.getUsername().equals(h.getUsername())) {
+                 h.notifyEvent(event);
+             }
+         });
+     }
+ 
+     /**
+      * Notifies all connected TCP clients of a new game model.
+      *
+      * @param model the updated mini model to send to the clients.
+      */
+     public void notifyAll(MiniModel model) {
+         clientHandlers.forEach(h -> h.notifyMiniModel(model));
+     }
+ 
+     /**
+      * Creates a {@link ClientHandler}, registers it in {@code pendingHeartbeat}
+      * and {@code clientHandlers}, but does NOT start its thread — callers start
+      * the thread after any extra setup (e.g. sending a model snapshot).
+      */
+     private ClientHandler createAndRegisterHandler(String username,
+                                                    Socket socket,
+                                                    ObjectOutputStream out,
+                                                    ObjectInputStream in) {
+         ClientHandler handler = new ClientHandler(
+                 username, socket, out, in, clientHandlers, playerList, actionQueue);
+         pendingHeartbeat.put(username, handler);
+         clientHandlers.add(handler);
+         return handler;
+     }
+ 
+     /** Returns usernames of players currently marked as disconnected in the given game. */
+     private static ArrayList<String> disconnectedUsernames(Game game) {
+         return game.getDisconnectedPlayers().entrySet().stream()
+                 .filter(Map.Entry::getValue)
+                 .map(e -> e.getKey().getUserName())
+                 .collect(Collectors.toCollection(ArrayList::new));
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index.html b/deliverables/Coverage/htmlReport/ns-12/index.html new file mode 100644 index 0000000..6d23daa --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..62971b8 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..ae466fe --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..3f8e5d1 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..d7ec019 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE.html new file mode 100644 index 0000000..a931949 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..1598621 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..0069a94 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..e2380f9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..6ad726f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,342 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.GUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.GUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.GUI + + 0% + + + (0/8) + + + + 0% + + + (0/130) + + + + 0% + + + (0/291) + + + + 0% + + + (0/1000) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
FireParticleSystem + + 0% + + + (0/3) + + + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-1.html new file mode 100644 index 0000000..54af74a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-1.html @@ -0,0 +1,413 @@ + + + + + + + + Coverage Report > FireParticleSystem + + + + + + +
+ + +

Coverage Summary for Class: FireParticleSystem (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class + Method, % + + Branch, % + + Line, % +
FireParticleSystem + + 0% + + + (0/6) + + + + 0% + + + (0/31) + + + + 0% + + + (0/50) + +
FireParticleSystem$1 + + 0% + + + (0/2) + + + + 0% + + + (0/2) + + + + 0% + + + (0/4) + +
FireParticleSystem$Particle + + 0% + + + (0/7) + + + + 0% + + + (0/40) + + + + 0% + + + (0/69) + +
Total + + 0% + + + (0/15) + + + + 0% + + + (0/73) + + + + 0% + + + (0/123) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import javafx.animation.AnimationTimer;
+ import javafx.scene.Scene;
+ import javafx.scene.layout.Pane;
+ import javafx.scene.paint.Color;
+ import javafx.scene.shape.Circle;
+ 
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ import java.util.List;
+ import java.util.Random;
+ 
+ //TODO ALL JAVADOC
+ public class FireParticleSystem {
+ 
+     private static final int  MAX_PARTICLES     = 30;
+     private static final long SPAWN_INTERVAL_NS = 100_000_000L;
+     private static final long FRAME_INTERVAL_NS = 1_000_000_000L / 30; // 30 fps cap
+     private static final int  STEPS_PER_FRAME   = 3; // physics steps per frame → 3× speed
+ 
+     private final Pane         pane;
+     private final Scene        scene;
+     private final List<Particle> particles = new ArrayList<>();
+     private final Random       rnd        = new Random();
+     private AnimationTimer     timer;
+     private long               lastSpawn  = 0;
+     private long               lastFrame  = 0;
+     private boolean            warmedUp   = false;
+ 
+     public FireParticleSystem(Scene scene) {
+         this.scene = scene;
+         pane = new Pane();
+         pane.setMouseTransparent(true);
+         pane.setPickOnBounds(false);
+     }
+ 
+     /** Returns the transparent overlay pane that holds all particle nodes. */
+     public Pane getPane() { return pane; }
+ 
+     /** Starts the animation timer. */
+     public void start() {
+         timer = new AnimationTimer() {
+             @Override
+             public void handle(long now) {
+                 if (now - lastFrame < FRAME_INTERVAL_NS) return;
+                 lastFrame = now;
+                 tick(now);
+             }
+         };
+         timer.start();
+     }
+ 
+     /** Stops the animation timer. */
+     public void stop() {
+         if (timer != null) timer.stop();
+     }
+ 
+     private void tick(long now) {
+         double w = scene.getWidth();
+         double h = scene.getHeight();
+         if (w == 0 || h == 0) return;
+ 
+         if (!warmedUp) {
+             warmedUp = true;
+             for (int i = 0; i < MAX_PARTICLES; i++) {
+                 Particle p = spawnParticle(w, h);
+                 int advance = rnd.nextInt(800) + 100;
+                 for (int f = 0; f < advance; f++) p.update();
+                 if (!p.isDead(w, h)) {
+                     p.addTo(pane);
+                     p.updateVisual(w, h);
+                     particles.add(p);
+                 }
+             }
+         }
+ 
+         if (now - lastSpawn > SPAWN_INTERVAL_NS && particles.size() < MAX_PARTICLES) {
+             lastSpawn = now;
+             int count = rnd.nextInt(2) + 1;
+             for (int i = 0; i < count && particles.size() < MAX_PARTICLES; i++) {
+                 Particle p = spawnParticle(w, h);
+                 p.addTo(pane);
+                 particles.add(p);
+             }
+         }
+ 
+         Iterator<Particle> it = particles.iterator();
+         while (it.hasNext()) {
+             Particle p = it.next();
+             for (int s = 0; s < STEPS_PER_FRAME; s++) p.update();
+             if (p.isDead(w, h)) {
+                 p.removeFrom(pane);
+                 it.remove();
+             } else {
+                 p.updateVisual(w, h);
+             }
+         }
+     }
+ 
+     private Particle spawnParticle(double w, double h) {
+         int    corner = rnd.nextInt(4);
+         double margin = 0.12;
+         double x, y;
+         switch (corner) {
+             case 0 -> { x = rnd.nextDouble() * w * margin;      y = h - rnd.nextDouble() * h * margin; }
+             case 1 -> { x = w - rnd.nextDouble() * w * margin;  y = h - rnd.nextDouble() * h * margin; }
+             case 2 -> { x = rnd.nextDouble() * w * margin;      y = rnd.nextDouble() * h * margin; }
+             default -> { x = w - rnd.nextDouble() * w * margin; y = rnd.nextDouble() * h * margin; }
+         }
+         return new Particle(x, y, w, h, corner, rnd);
+     }
+ 
+     // ── Particle ──────────────────────────────────────────────────────────────
+ 
+     private static class Particle {
+ 
+         double x, y, vx, vy;
+         double life;
+         double size;
+         double wobblePhase, wobbleSpeed, wobbleAmp;
+         final int    type;
+         final Random rnd;
+ 
+         final Circle core;
+         final Circle glow; // non-null only for embers
+ 
+         Particle(double x, double y, double w, double h, int corner, Random rnd) {
+             this.x   = x;
+             this.y   = y;
+             this.life = 1.0;
+             this.rnd  = rnd;
+             this.type = weightedType(rnd);
+ 
+             double targetX  = (corner == 0 || corner == 2) ? w * 0.75 : w * 0.25;
+             double targetY  = (corner == 0 || corner == 1) ? h * 0.25 : h * 0.75;
+             double baseAngle = Math.atan2(targetY - y, targetX - x);
+             double angle     = baseAngle + (rnd.nextDouble() - 0.5) * (Math.PI / 3.5);
+ 
+             double speed;
+             if (type == 0) {           // ember
+                 speed = 0.5 + rnd.nextDouble() * 0.7;
+                 size  = rnd.nextDouble() * 3 + 2;
+                 glow  = new Circle(size * 2.2);
+                 core  = new Circle(size / 2);
+             } else if (type == 1) {    // spark
+                 speed = 1.5 + rnd.nextDouble() * 2.0;
+                 size  = rnd.nextDouble() * 1.5 + 0.5;
+                 glow  = null;
+                 core  = new Circle(size / 2);
+             } else {                   // dust
+                 speed = 0.2 + rnd.nextDouble() * 0.35;
+                 size  = rnd.nextDouble() * 8 + 5;
+                 glow  = null;
+                 core  = new Circle(size);
+                 core.setFill(Color.color(0.55, 0.38, 0.22));
+             }
+ 
+             vx = Math.cos(angle) * speed;
+             vy = Math.sin(angle) * speed;
+             wobblePhase = rnd.nextDouble() * Math.PI * 2;
+             wobbleSpeed = 0.025 + rnd.nextDouble() * 0.04;
+             wobbleAmp   = 0.1   + rnd.nextDouble() * 0.4;
+         }
+ 
+         private static int weightedType(Random rnd) {
+             double r = rnd.nextDouble();
+             if (r < 0.55) return 0;
+             if (r < 0.78) return 1;
+             return 2;
+         }
+ 
+         void addTo(Pane pane) {
+             if (glow != null) pane.getChildren().add(glow);
+             pane.getChildren().add(core);
+         }
+ 
+         void removeFrom(Pane pane) {
+             pane.getChildren().remove(core);
+             if (glow != null) pane.getChildren().remove(glow);
+         }
+ 
+         void update() {
+             wobblePhase += wobbleSpeed;
+             vx += Math.sin(wobblePhase) * wobbleAmp * 0.05;
+             vy += Math.cos(wobblePhase) * wobbleAmp * 0.02;
+             x  += vx;
+             y  += vy;
+             if (type == 1) life -= 0.008 + rnd.nextDouble() * 0.006;
+         }
+ 
+         boolean isDead(double w, double h) {
+             double pad = size * 4;
+             return x < -pad || x > w + pad || y < -pad || y > h + pad
+                     || (type == 1 && life <= 0);
+         }
+ 
+         void updateVisual(double w, double h) {
+             double edge     = Math.min(w, h) * 0.05;
+             double fadeX    = Math.min(x / edge,       Math.min((w - x) / edge, 1.0));
+             double fadeY    = Math.min(y / edge,       Math.min((h - y) / edge, 1.0));
+             double posAlpha = Math.max(0, Math.min(fadeX, fadeY));
+             double lifeAlpha = (type == 1) ? Math.min(life * 2.0, 1.0) : 1.0;
+             double alpha    = posAlpha * lifeAlpha;
+ 
+             core.setTranslateX(x);
+             core.setTranslateY(y);
+ 
+             if (type == 0) {
+                 double dist    = Math.sqrt((x - w/2) * (x - w/2) + (y - h/2) * (y - h/2));
+                 double hotness = Math.max(0, 1.0 - dist / (Math.sqrt(w * w + h * h) * 0.4));
+                 double g       = 0.3 + hotness * 0.5;
+                 core.setFill(Color.color(1.0, g, 0.0));
+                 core.setOpacity(alpha * 0.88);
+                 glow.setTranslateX(x);
+                 glow.setTranslateY(y);
+                 glow.setFill(Color.color(1.0, g * 0.35, 0.0));
+                 glow.setOpacity(alpha * 0.10);
+             } else if (type == 1) {
+                 double brightness = Math.min(life * 2.5, 1.0);
+                 core.setFill(Color.color(1.0, brightness * 0.85 + 0.15, brightness * 0.15));
+                 core.setOpacity(alpha);
+             } else {
+                 core.setOpacity(alpha * 0.20);
+             }
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-2.html new file mode 100644 index 0000000..b148f7b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-2.html @@ -0,0 +1,398 @@ + + + + + + + + Coverage Report > GUI + + + + + + +
+ + +

Coverage Summary for Class: GUI (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
GUI + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/22) + + + + 0% + + + (0/116) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.View.IView;
+ import javafx.animation.FadeTransition;
+ import javafx.application.Application;
+ import javafx.application.Platform;
+ import javafx.fxml.FXMLLoader;
+ import javafx.geometry.Rectangle2D;
+ import javafx.scene.Parent;
+ import javafx.scene.Scene;
+ import javafx.scene.input.KeyCode;
+ import javafx.scene.input.KeyEvent;
+ import javafx.scene.input.KeyCombination;
+ import javafx.scene.layout.StackPane;
+ import javafx.scene.media.Media;
+ import javafx.scene.media.MediaPlayer;
+ import javafx.scene.paint.Color;
+ import javafx.scene.shape.Rectangle;
+ import javafx.stage.Screen;
+ import javafx.stage.Stage;
+ import javafx.util.Duration;
+ 
+ import static it.polimi.ingsw.gc14.Model.GamePackage.GameStages.ENDED;
+ import static it.polimi.ingsw.gc14.Model.GamePackage.GameStages.TOTEM_CHOICE;
+ 
+ /**
+  * JavaFX-based GUI implementation of {@link it.polimi.ingsw.gc14.View.IView IView}.
+  *
+  * <p>Manages the primary stage and switches between the login, totem choice,
+  * main game, and leaderboard scenes based on the current game state.
+  */
+ public class GUI extends Application implements IView {
+     //TODO
+     private Stage primaryStage;
+     //TODO
+     private volatile MiniModel miniModel;
+     //TODO
+     private FXMLLoader loaderLogin;
+     //TODO
+     private Scene loginScene;
+     //TODO
+     private LoginFXMLController controllerLogin;
+     //TODO
+     private FXMLLoader loaderTotem;
+     //TODO
+     private Scene totemScene;
+     //TODO
+     private TotemFXMLController controllerTotem;
+     //TODO
+     private FXMLLoader loaderMain;
+ 
+     //TODO
+     private Scene mainScene;
+     //TODO
+     private MainFXMLController controllerMain;
+     //TODO
+     private FXMLLoader loaderLeaderboard;
+     //TODO
+     private Scene leaderboardScene;
+     //TODO
+     private LeaderboardFXMLController controllerLeaderboard;
+ 
+     //TODO
+     private ClientController controller;
+     //TODO
+     private boolean autoReenterFullscreen = true;
+     //TODO
+     private boolean isFading = false;
+     //TODO
+     private MediaPlayer bgMusic;
+ 
+ 
+     /**
+      * JavaFX entry point: loads all FXML scenes, wires up controllers,
+      * configures fullscreen behaviour, and shows the login scene.
+      *
+      * @param stage the primary stage provided by the JavaFX runtime.
+      * @throws Exception if any FXML resource cannot be loaded.
+      */
+     @Override
+     public void start(Stage stage) throws Exception {
+         this.primaryStage = stage;
+         loaderLogin = new FXMLLoader(getClass().getResource("/GUIScene/login.fxml"));
+         loginScene = new Scene(loaderLogin.load());
+         controllerLogin = loaderLogin.getController();
+         controllerLogin.setController(controller);
+ 
+ 
+         loaderTotem = new FXMLLoader(getClass().getResource("/GUIScene/totem.fxml"));
+         totemScene = new Scene(loaderTotem.load());
+         controllerTotem = loaderTotem.getController();
+         controllerTotem.setController(controller);
+ 
+ 
+         loaderMain = new FXMLLoader(getClass().getResource("/GUIScene/main.fxml"));
+         mainScene = new Scene(loaderMain.load());
+         controllerMain = loaderMain.getController();
+         controllerMain.setController(controller);
+ 
+         loaderLeaderboard = new FXMLLoader(getClass().getResource("/GUIScene/standing.fxml"));
+         leaderboardScene = new Scene(loaderLeaderboard.load());
+         controllerLeaderboard = loaderLeaderboard.getController();
+         controllerLeaderboard.setController(controller, () -> {
+             controllerLogin.updateLoginButton(true);
+             controllerLogin.showError("");
+             fadeToScene(loginScene);
+         }, loginScene);
+ 
+ 
+ 
+ 
+ 
+         wrapScene(loginScene);
+         wrapScene(totemScene);
+         wrapScene(mainScene);
+         wrapScene(leaderboardScene);
+ 
+         FireParticleSystem fireParticles = new FireParticleSystem(mainScene);
+         ((StackPane) mainScene.getRoot()).getChildren().add(fireParticles.getPane());
+         fireParticles.start();
+ 
+         primaryStage.setScene(loginScene);
+         Rectangle2D tmp = Screen.getPrimary().getVisualBounds();
+         primaryStage.setWidth(tmp.getWidth());
+         primaryStage.setHeight(tmp.getHeight());
+         primaryStage.setX(tmp.getMinX());
+         primaryStage.setY(tmp.getMinY());
+         primaryStage.setResizable(false);
+         primaryStage.setFullScreenExitHint("");
+         primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
+ 
+         primaryStage.fullScreenProperty().addListener((obs, was, isNow) -> {
+             if (!isNow && autoReenterFullscreen) {
+                 Platform.runLater(() -> primaryStage.setFullScreen(true));
+             }
+         });
+ 
+         primaryStage.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
+             if (e.getCode() == KeyCode.ESCAPE) {
+                 autoReenterFullscreen = false;
+                 primaryStage.setFullScreen(false);
+                 e.consume();
+             } else if (e.getCode() == KeyCode.F11) {
+                 autoReenterFullscreen = true;
+                 primaryStage.setFullScreen(true);
+                 e.consume();
+             }
+         });
+ 
+         primaryStage.setTitle("Mesos");
+         primaryStage.setOnCloseRequest(e -> {
+             Platform.exit();
+             System.exit(0);
+         });
+         primaryStage.show();
+         Platform.runLater(() -> primaryStage.setFullScreen(true));
+ 
+         try {
+             String musicUrl = getClass().getResource("/Audio/Music.mp3").toExternalForm();
+             bgMusic = new MediaPlayer(new Media(musicUrl));
+             bgMusic.setCycleCount(MediaPlayer.INDEFINITE);
+             bgMusic.setVolume(0.4);
+             bgMusic.play();
+         } catch (Exception e) {
+             System.err.println("Audio unavailable: " + e.getMessage());
+         }
+     }
+ 
+ 
+     /**
+      * Updates the local mini model reference used by the GUI.
+      *
+      * @param miniModel the latest mini model received from the server.
+      */
+     @Override
+     public void setModel(MiniModel miniModel) {
+         this.miniModel = miniModel;
+     }
+ 
+     /**
+      * Injects the client controller into this GUI.
+      *
+      * @param controller the client controller to use.
+      */
+     public void setController(ClientController controller) {
+         this.controller=controller;
+     }
+ 
+     /**
+      * Re-renders the GUI on the JavaFX application thread, switching to the
+      * appropriate scene based on the current game stage.
+      */
+     public void render() {
+         Platform.runLater(() -> {
+             if (miniModel == null) return;
+             if (controller.getMiniModel().currentState.getGameStage() == TOTEM_CHOICE) {
+                 controllerTotem.render();
+                 fadeToScene(totemScene);
+             } else if (controller.getMiniModel().currentState.getGameStage() == ENDED) {
+                 controllerLeaderboard.render();
+                 fadeToScene(leaderboardScene);
+             } else {
+                 controllerMain.render();
+                 fadeToScene(mainScene);
+             }
+         });
+     }
+     //TODO
+     private void wrapScene(Scene scene) {
+         Parent root = scene.getRoot();
+         scene.setRoot(new StackPane(root));
+     }
+     //TODO
+     private void fadeToScene(Scene newScene) {
+         Scene currentScene = primaryStage.getScene();
+         if (currentScene == newScene || isFading) return;
+         isFading = true;
+ 
+         StackPane currentRoot = (StackPane) currentScene.getRoot();
+         Rectangle overlay = new Rectangle();
+         overlay.setFill(Color.BLACK);
+         overlay.setOpacity(0);
+         overlay.widthProperty().bind(currentRoot.widthProperty());
+         overlay.heightProperty().bind(currentRoot.heightProperty());
+         currentRoot.getChildren().add(overlay);
+ 
+         FadeTransition fadeOut = new FadeTransition(Duration.millis(500), overlay);
+         fadeOut.setFromValue(0);
+         fadeOut.setToValue(1);
+         fadeOut.setOnFinished(e -> {
+             currentRoot.getChildren().remove(overlay);
+ 
+             StackPane newRoot = (StackPane) newScene.getRoot();
+             Rectangle newOverlay = new Rectangle();
+             newOverlay.setFill(Color.BLACK);
+             newOverlay.setOpacity(1);
+             newOverlay.widthProperty().bind(newRoot.widthProperty());
+             newOverlay.heightProperty().bind(newRoot.heightProperty());
+             newRoot.getChildren().add(newOverlay);
+ 
+             primaryStage.setScene(newScene);
+ 
+             FadeTransition fadeIn = new FadeTransition(Duration.millis(500), newOverlay);
+             fadeIn.setFromValue(1);
+             fadeIn.setToValue(0);
+             fadeIn.setOnFinished(ev -> {
+                 newRoot.getChildren().remove(newOverlay);
+                 isFading = false;
+             });
+             fadeIn.play();
+         });
+         fadeOut.play();
+     }
+ 
+     /**
+      * Displays an error on the JavaFX application thread.
+      *
+      * <p>If the server crashed, returns to the login scene and re-enables the login button.
+      * Otherwise delegates to the active scene's error display.
+      *
+      * @param error   the error type.
+      * @param message a human-readable description of the error.
+      */
+     @Override
+     public void showError(ErrorType error,String message) {
+         Platform.runLater(() -> {
+             if (error == ErrorType.SERVER_CRASHED) {
+                 controllerLogin.updateLoginButton(true);
+                 controllerLogin.showError(error);
+                 fadeToScene(loginScene);
+             } else {
+                 if (miniModel == null) return;
+                 controllerMain.setError(true);
+                 controllerMain.render();
+             }
+         });
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-3.html new file mode 100644 index 0000000..6bc607c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-3.html @@ -0,0 +1,498 @@ + + + + + + + + Coverage Report > LeaderboardFXMLController + + + + + + +
+ + +

Coverage Summary for Class: LeaderboardFXMLController (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
LeaderboardFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/19) + + + + 0% + + + (0/34) + + + + 0% + + + (0/182) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import javafx.animation.ScaleTransition;
+ import it.polimi.ingsw.gc14.Model.PlayableCard;
+ import javafx.event.Event;
+ import javafx.fxml.FXML;
+ import javafx.scene.Scene;
+ import javafx.scene.control.ScrollPane;
+ import javafx.stage.Popup;
+ import javafx.geometry.Insets;
+ import javafx.geometry.Pos;
+ import javafx.scene.Cursor;
+ import javafx.scene.Node;
+ import javafx.scene.control.Label;
+ import javafx.scene.effect.DropShadow;
+ import javafx.scene.image.Image;
+ import javafx.scene.image.ImageView;
+ import javafx.scene.input.MouseEvent;
+ import javafx.scene.layout.*;
+ import javafx.scene.paint.Color;
+ import javafx.scene.paint.LinearGradient;
+ import javafx.scene.paint.Stop;
+ import javafx.scene.paint.CycleMethod;
+ import javafx.scene.text.Font;
+ import javafx.stage.Stage;
+ import javafx.stage.Window;
+ import javafx.util.Duration;
+ 
+ import java.util.*;
+ 
+ /**
+  * FXML controller for the end-of-game leaderboard scene.
+  *
+  * <p>Displays the final player rankings and a winner/game-over banner.
+  */
+ public class LeaderboardFXMLController {
+ 
+     @FXML private StackPane rootPane;
+     @FXML private VBox mainVBox;
+     @FXML private VBox rankingList;
+     // title label removed; outcome text is added dynamically in render()
+     //TODO
+     private ClientController controller;
+     //TODO
+     private Popup popup;
+     //TODO
+     private VBox popupContent;
+     //TODO
+     private static final Map<String, Image> imageCache = new HashMap<>();
+     //TODO
+     private Scene loginScene;
+ 
+     //TODO
+     private Runnable action;
+ 
+     /** Returns a cached {@link Image} for the given classpath {@code path}, loading it on first access. */
+     private Image loadImage(String path) {
+         return imageCache.computeIfAbsent(path,
+                 p -> new Image(getClass().getResourceAsStream(p)));
+     }
+ 
+ 
+     /**
+      * Injects the client controller, a post-game action, and the login scene reference.
+      *
+      * @param controller  the client controller.
+      * @param action      the action to run when the player returns to the login screen.
+      * @param loginScene  the login scene to show on exit.
+      */
+     public void setController(ClientController controller, Runnable action, Scene loginScene) {
+         this.controller = controller;
+         this.loginScene = loginScene;
+         this.action = action;
+     }
+ 
+ 
+     /** Initializes the scene: loads fonts, sets up the background, and initializes the popup. */
+     @FXML
+     public void initialize() {
+         Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 14);
+         mainVBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
+             if (newScene != null) newScene.getRoot().applyCss();
+         });
+         renderBackground();
+         initPopup();
+     }
+ 
+ 
+     /** Populates the ranking list with the final player standings and shows the outcome banner. */
+     public void render() {
+         rankingList.getChildren().clear();
+         if(!controller.getMiniModel().standingPlayers.isEmpty())
+         {
+             List<Player> sorted = controller.getMiniModel().standingPlayers;
+ 
+             boolean iWon = sorted.get(0).getUserName().equals(controller.getMyUsername());
+ 
+             // Label grande Winner / Game Over
+             Label outcomeLabel = new Label(iWon ? "\uD83C\uDFC6 WINNER! \uD83C\uDFC6" : "GAME OVER");
+             outcomeLabel.setStyle(
+                     "-fx-font-size: 64px;" +
+                             "-fx-font-weight: bold;" +
+                             "-fx-text-fill: " + (iWon ? "#FFD700;" : "#FF4444;")
+             );
+             DropShadow glow = new DropShadow();
+             glow.setColor(iWon ? Color.rgb(255, 200, 0, 0.95) : Color.rgb(220, 0, 0, 0.95));
+             glow.setRadius(35);
+             glow.setSpread(0.35);
+             outcomeLabel.setEffect(glow);
+             rankingList.getChildren().add(outcomeLabel);
+ 
+             Region sep = new Region();
+             sep.setPrefHeight(16);
+             rankingList.getChildren().add(sep);
+ 
+             for (int i = 0; i < sorted.size(); i++) {
+                 rankingList.getChildren().add(createPlayerRow(i + 1, sorted.get(i)));
+             }
+         }
+     }
+ 
+ 
+     // ==== EFFECTS ====
+     /** Scales {@code node} to 1.02× on hover and sets a hand cursor. */
+     private void addHoverZoom(Node node) {
+         ScaleTransition scaleUp = new ScaleTransition(Duration.millis(150), node);
+         scaleUp.setToX(1.02);
+         scaleUp.setToY(1.02);
+         ScaleTransition scaleDown = new ScaleTransition(Duration.millis(150), node);
+         scaleDown.setToX(1.0);
+         scaleDown.setToY(1.0);
+         node.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> { scaleUp.play(); node.setCursor(Cursor.HAND); });
+         node.addEventHandler(MouseEvent.MOUSE_EXITED,  e -> { scaleDown.play(); node.setCursor(Cursor.DEFAULT); });
+     }
+ 
+     /** Applies a static drop-shadow to {@code node}. */
+     private void addShadow(Node node) {
+         DropShadow shadow = new DropShadow();
+         shadow.setColor(Color.rgb(0, 0, 0, 0.6));
+         shadow.setRadius(12);
+         shadow.setOffsetX(3);
+         shadow.setOffsetY(3);
+         node.setEffect(shadow);
+     }
+ 
+ 
+     // ==== ROW ====
+     /** Builds a styled leaderboard row showing rank, totem, username, stats, and prestige for {@code player}. */
+     private HBox createPlayerRow(int position, Player player) {
+         HBox row = new HBox(20);
+         row.setAlignment(Pos.CENTER_LEFT);
+         row.setPadding(new Insets(14, 28, 14, 28));
+         row.setMaxWidth(Double.MAX_VALUE);
+ 
+         LinearGradient gradient = new LinearGradient(
+                 0, 0, 1, 0, true, CycleMethod.NO_CYCLE,
+                 new Stop(0.0, Color.rgb(0, 0, 0, 0.75)),
+                 new Stop(0.5, Color.rgb(0, 0, 0, 0.60)),
+                 new Stop(1.0, Color.rgb(0, 0, 0, 0.75))
+         );
+         row.setBackground(new Background(new BackgroundFill(
+                 gradient,
+                 new CornerRadii(12),
+                 Insets.EMPTY
+         )));
+         addShadow(row);
+         addHoverZoom(row);
+ 
+         Label posLabel = new Label(position + "°");
+         posLabel.setMinWidth(55);
+         String medalColor = switch (position) {
+             case 1  -> "#FFD700"; // oro
+             case 2  -> "#C0C0C0"; // argento
+             case 3  -> "#CD7F32"; // bronzo
+             default -> "#EEEEEE";
+         };
+         posLabel.setStyle("-fx-font-size: 28px; -fx-font-weight: bold; -fx-text-fill: " + medalColor + ";");
+ 
+ 
+         ImageView totem = new ImageView(loadImage(
+                 "/GUIImages/Totems/totem_" + player.getTotem().toString().toLowerCase(Locale.ROOT) + ".png"));
+         totem.setFitHeight(55);
+         totem.setPreserveRatio(true);
+ 
+         Label nameLabel = new Label(player.getUserName());
+         nameLabel.setStyle(
+                 "-fx-font-size: 22px; -fx-font-weight: bold; -fx-text-fill: " +
+                         (player.getUserName().equals(controller.getMyUsername()) ? "#ff6b6b;" : "#FFFFFF;")
+         );
+         HBox.setHgrow(nameLabel, Priority.ALWAYS);
+ 
+         HBox stats = createStatsBox(player);
+ 
+         HBox ppBox = new HBox(6);
+         ppBox.setAlignment(Pos.CENTER);
+         ImageView ppIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png"));
+         ppIcon.setFitHeight(45);
+         ppIcon.setPreserveRatio(true);
+         Label ppLabel = new Label(String.valueOf(player.getPrestigeValue()));
+         ppLabel.setStyle("-fx-font-size: 28px; -fx-font-weight: bold; -fx-text-fill: #FFD700;");
+         ppBox.getChildren().addAll(ppIcon, ppLabel);
+ 
+         row.getChildren().addAll(posLabel, totem, nameLabel, stats, ppBox);
+         row.setOnMouseClicked(e -> openPlayerPopup(player));
+         return row;
+     }
+ 
+     /** Creates a compact icon+count stats strip for all card types of {@code player}. */
+     private HBox createStatsBox(Player player) {
+         HBox stats = new HBox(14);
+         stats.setAlignment(Pos.CENTER);
+ 
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Food.png",     String.valueOf(player.getFoodValue()),           26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Artist.png",   String.valueOf(player.getArtists().size()),   26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Gatherer.png", String.valueOf(player.getGatherers().size()), 26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Inventor.png", String.valueOf(player.getInventors().size()), 26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Builder.png",  String.valueOf(player.getBuilders().size()),  26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Shaman.png",   String.valueOf(player.getShamans().size()),   26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Hunter.png",   String.valueOf(player.getHunters().size()),   26));
+         stats.getChildren().add(createStatItem("/GUIImages/Icons/Building.png", String.valueOf(player.getBuildingCards().size()), 26));
+ 
+         return stats;
+     }
+ 
+     /** Creates a single icon + label widget for one stat type. */
+     private HBox createStatItem(String iconPath, String value, double iconHeight) {
+         HBox box = new HBox(4);
+         box.setAlignment(Pos.CENTER);
+         ImageView icon = new ImageView(loadImage(iconPath));
+         icon.setFitHeight(iconHeight);
+         icon.setPreserveRatio(true);
+         Label label = new Label(value);
+         label.setStyle("-fx-font-size: 16px; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
+         DropShadow textShadow = new DropShadow();
+         textShadow.setColor(Color.rgb(0, 0, 0, 0.9));
+         textShadow.setRadius(4);
+         label.setEffect(textShadow);
+         box.getChildren().addAll(icon, label);
+         return box;
+     }
+ 
+ 
+     // ==== POPUP ====
+     /** Creates and configures the auto-hiding player-detail popup. */
+     private void initPopup() {
+         popupContent = new VBox(12);
+         popupContent.setAlignment(Pos.CENTER);
+         popupContent.setPadding(new Insets(16));
+         popupContent.setStyle(
+                 "-fx-background-color: rgba(20,10,5,0.97);" +
+                         "-fx-border-color: #8B4513;" +
+                         "-fx-border-width: 3;" +
+                         "-fx-border-radius: 14;" +
+                         "-fx-background-radius: 14;"
+         );
+ 
+         popup = new Popup();
+         popup.getContent().add(popupContent);
+         popup.setAutoHide(true);
+         popup.addEventHandler(Event.ANY, e -> {
+             if (popup.getScene() != null) popup.getScene().setFill(Color.TRANSPARENT);
+         });
+     }
+ 
+     /** Opens the player-detail popup showing all cards held by {@code player}, grouped by type. */
+     private void openPlayerPopup(Player player) {
+         popupContent.getChildren().clear();
+ 
+         HBox header = new HBox(10);
+         header.setAlignment(Pos.CENTER);
+         ImageView totem = new ImageView(loadImage(
+                 "/GUIImages/Totems/totem_" + player.getTotem().toString().toLowerCase(Locale.ROOT) + ".png"));
+         totem.setFitHeight(30);
+         totem.setPreserveRatio(true);
+         Label nameLabel = new Label(player.getUserName());
+         nameLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold; -fx-text-fill: #FFD700;");
+         header.getChildren().addAll(totem, nameLabel);
+         popupContent.getChildren().add(header);
+ 
+         String[][] types = {
+                 {"Artist",   "artists"},
+                 {"Gatherer", "gatherers"},
+                 {"Inventor", "inventors"},
+                 {"Builder",  "builders"},
+                 {"Shaman",   "shamans"},
+                 {"Hunter",   "hunters"},
+                 {"Building", "buildingCards"}
+         };
+ 
+         VBox grid = new VBox(6);
+         grid.setAlignment(Pos.CENTER_LEFT);
+         boolean hasAnyCard = false;
+ 
+         for (String[] type : types) {
+             String typeName = type[0];
+             String field    = type[1];
+             ArrayList<PlayableCard> cards = getPlayerCards(player.getUserName(), field);
+             if (cards.isEmpty()) continue;
+             hasAnyCard = true;
+ 
+             HBox row = new HBox(6);
+             row.setAlignment(Pos.CENTER_LEFT);
+ 
+             ImageView typeIcon = new ImageView(loadImage("/GUIImages/Icons/"+typeName+".png"));
+             typeIcon.setFitHeight(22);
+             typeIcon.setPreserveRatio(true);
+             row.getChildren().add(typeIcon);
+ 
+             for (PlayableCard card : cards) {
+                 ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
+                 img.setFitHeight(230);
+                 img.setPreserveRatio(true);
+                 img.setCursor(Cursor.HAND);
+                 row.getChildren().add(img);
+             }
+ 
+             grid.getChildren().add(row);
+         }
+ 
+         if (!hasAnyCard) {
+             Label empty = new Label("No cards");
+             empty.setStyle("-fx-font-size: 14px; -fx-text-fill: #888888;");
+             grid.getChildren().add(empty);
+         }
+ 
+         ScrollPane scrollPane = new ScrollPane(grid);
+         scrollPane.setFitToWidth(true);
+         scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
+         scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
+         scrollPane.setStyle("-fx-background: transparent; -fx-background-color: transparent;");
+ 
+         Window window = rootPane.getScene().getWindow();
+         scrollPane.setMaxHeight(window.getHeight() * 0.8); // cap scroll area to 80% of window height
+         popupContent.getChildren().add(scrollPane);
+         popup.show(window, 0, 0);
+         popup.getScene().setFill(Color.TRANSPARENT);
+         popup.setX(window.getX() + (window.getWidth()  - popup.getWidth())  / 2);
+         popup.setY(window.getY() + (window.getHeight() - popup.getHeight()) / 2);
+     }
+ 
+     /** Returns a copy of the named card collection for {@code username}. */
+     private ArrayList<PlayableCard> getPlayerCards(String username, String type) {
+         Player p = controller.getMiniModel().players.get(username);
+         return switch (type) {
+             case "artists"       -> new ArrayList<>(p.getArtists());
+             case "gatherers"     -> new ArrayList<>(p.getGatherers());
+             case "inventors"     -> new ArrayList<>(p.getInventors());
+             case "builders"      -> new ArrayList<>(p.getBuilders());
+             case "shamans"       -> new ArrayList<>(p.getShamans());
+             case "hunters"       -> new ArrayList<>(p.getHunters());
+             case "buildingCards" -> new ArrayList<>(p.getBuildingCards());
+             default              -> new ArrayList<>();
+         };
+     }
+ 
+     // ==== BACKGROUND ====
+     /** Sets the full-cover background image on the root pane. */
+     private void renderBackground() {
+         BackgroundSize size = new BackgroundSize(
+                 BackgroundSize.AUTO, BackgroundSize.AUTO,
+                 false, false, true, true
+         );
+         rootPane.setBackground(new Background(new BackgroundImage(
+                 loadImage("/GUIImages/Background.png"),
+                 BackgroundRepeat.NO_REPEAT,
+                 BackgroundRepeat.NO_REPEAT,
+                 BackgroundPosition.CENTER,
+                 size
+         )));
+     }
+ 
+ 
+     // ==== ACTIONS ====
+     /** Disconnects the client and invokes the post-game action to return to the login scene. */
+     @FXML
+     private void onNewGame() {
+         controller.disconnect();
+         action.run();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-4.html new file mode 100644 index 0000000..ae9add3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-4.html @@ -0,0 +1,329 @@ + + + + + + + + Coverage Report > LoginFXMLController + + + + + + +
+ + +

Coverage Summary for Class: LoginFXMLController (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
LoginFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/14) + + + + 0% + + + (0/14) + + + + 0% + + + (0/63) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.InterfaceResolver;
+ import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
+ import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
+ import javafx.animation.*;
+ import javafx.application.Platform;
+ import javafx.css.PseudoClass;
+ import javafx.fxml.FXML;
+ import javafx.geometry.Rectangle2D;
+ import javafx.scene.control.*;
+ import javafx.scene.image.Image;
+ import javafx.scene.image.ImageView;
+ import javafx.scene.layout.*;
+ import javafx.scene.paint.Color;
+ import javafx.stage.Screen;
+ import javafx.util.Duration;
+ 
+ import java.net.*;
+ import java.util.Enumeration;
+ 
+ /**
+  * FXML controller for the login scene.
+  *
+  * <p>Handles username/IP/player-count input, protocol selection (TCP/RMI),
+  * and initiates the connection to the server.
+  */
+ public class LoginFXMLController {
+     //TODO
+     @FXML private ImageView backgroundImage;
+     //TODO
+     @FXML private TextField campoNome;
+     //TODO
+     @FXML private TextField campoNumPlayers;
+     //TODO
+     @FXML private TextField campoIP;
+     //TODO
+     @FXML private Button btnAccedi;
+     //TODO
+     @FXML private Label labelErrore;
+     //TODO
+     @FXML private VBox formPanel;
+     //TODO
+     @FXML private StackPane protocolToggle;
+     //TODO
+     @FXML private Region toggleThumb;
+     //TODO
+     @FXML private Label labelRMI;
+     //TODO
+     @FXML private Label labelTCP;
+     //TODO
+     private boolean isRMI = true;
+     //TODO
+     private ClientController controller;
+     //TODO
+     private final PseudoClass activeProtocolPseudo = PseudoClass.getPseudoClass("active-protocol");
+ 
+     /**
+      * Injects the client controller into this FXML controller.
+      *
+      * @param controller the client controller to use.
+      */
+     public void setController(ClientController controller) {
+         this.controller = controller;
+     }
+ 
+     /** Initializes the scene: loads background, sets up animations, and binds input listeners. */
+     @FXML
+     public void initialize() {
+         // Background setup
+         Image img = new Image(getClass().getResourceAsStream("/GUIImages/BackgroundLogin.png"));
+         backgroundImage.setImage(img);
+         Rectangle2D screenBounds = Screen.getPrimary().getBounds();
+         backgroundImage.setFitWidth(screenBounds.getWidth());
+         backgroundImage.setFitHeight(screenBounds.getHeight());
+ 
+         // Protocol toggle configuration
+         protocolToggle.setOnMouseClicked(e -> switchProtocol());
+         protocolToggle.setStyle(protocolToggle.getStyle() + " -fx-cursor: hand;");
+ 
+         labelRMI.pseudoClassStateChanged(activeProtocolPseudo, true);
+         labelTCP.pseudoClassStateChanged(activeProtocolPseudo, false);
+ 
+         // Login Action
+         btnAccedi.setOnAction(e -> onAccediClick());
+     }
+ 
+     /** Toggles the selected protocol between RMI and TCP, animating the toggle thumb and updating label styles. */
+     private void switchProtocol() {
+         isRMI = !isRMI;
+ 
+         TranslateTransition tt = new TranslateTransition(Duration.millis(200), toggleThumb);
+         tt.setToX(isRMI ? 0 : 110);
+         tt.play();
+ 
+         // pseudoClassStateChanged preserves layout properties unlike direct style mutation
+         labelRMI.pseudoClassStateChanged(activeProtocolPseudo, isRMI);
+         labelTCP.pseudoClassStateChanged(activeProtocolPseudo, !isRMI);
+     }
+ 
+     /** Validates form input and starts a background thread to connect to the server. */
+     @FXML
+     private void onAccediClick() {
+         String name = campoNome.getText().trim();
+         String ip   = campoIP.getText().trim();
+ 
+         if (name.isEmpty()) {
+             showError("Please select a name.");
+             return;
+         }
+ 
+         int numPlayers;
+         try {
+             numPlayers = Integer.parseInt(campoNumPlayers.getText().trim());
+         } catch (NumberFormatException e) {
+             showError("Invalid number of players.");
+             return;
+         }
+ 
+         updateLoginButton(false);
+         controller.setMyUsername(name);
+ 
+         new Thread(() -> {
+             try {
+                 String localInterface = InterfaceResolver.resolveLocalInterface(ip);
+                 System.setProperty("java.rmi.server.hostname", localInterface);
+                 connect(name, ip, numPlayers, localInterface);
+             } catch (Exception ex) {
+                 Platform.runLater(() -> {
+                     showError("Network error: " + ex.getMessage());
+                     updateLoginButton(true);
+                 });
+             }
+         }).start();
+     }
+ 
+     /**
+      * Enables or disables the login button and updates its visual style.
+      *
+      * @param enabled {@code true} to enable the button, {@code false} to disable it.
+      */
+     public void updateLoginButton(boolean enabled) {
+         btnAccedi.setDisable(!enabled);
+         btnAccedi.setStyle(
+                 "-fx-font-family: 'Cinzel'; -fx-font-size: 12; -fx-font-weight: bold;" +
+                 "-fx-letter-spacing: 4; -fx-text-fill: #0c0601;" +
+                 "-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
+                 "-fx-padding: 13 48 13 48; -fx-background-radius: 2;" +
+                 "-fx-opacity: " + (enabled ? "1.0" : "0.3") + ";" +
+                 "-fx-cursor: " + (enabled ? "hand" : "default") + ";"
+         );
+     }
+ 
+ 
+ 
+ 
+     /** Connects to the server using the selected protocol and transitions to the waiting state on success. */
+     private void connect(String nome, String ip, int numPlayers, String localInterface) {
+         if (isRMI) {
+             RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, localInterface);
+             ErrorType serverResponse = client.connect(nome, numPlayers);
+             if (serverResponse == null) {
+                 controller.setClient(client);
+                 Platform.runLater(() -> showSuccess("Connected! Waiting for other players…"));
+             } else {
+                 Platform.runLater(() -> {
+                     showError(serverResponse);
+                     updateLoginButton(true);
+                 });
+             }
+         } else {
+             TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
+             ErrorType serverResponse = client.connect(nome, numPlayers);
+             if (serverResponse == null) {
+                 controller.setClient(client);
+                 Platform.runLater(() -> showSuccess("Connected! Waiting for other players…"));
+             } else {
+                 Platform.runLater(() -> {
+                     showError(serverResponse);
+                     updateLoginButton(true);
+                 });
+             }
+         }
+     }
+     /**
+      * Displays an error from an {@link ErrorType} constant in the login form label.
+      *
+      * @param errorType the error to display.
+      */
+     public void showError(ErrorType errorType) {
+         labelErrore.setTextFill(Color.web("#e05050"));
+         labelErrore.setText(errorType.toString());
+     }
+ 
+     /**
+      * Displays an arbitrary error message in the login form label.
+      *
+      * @param msg the error message to display.
+      */
+     public void showError(String msg) {
+         labelErrore.setTextFill(Color.web("#e05050"));
+         labelErrore.setText(msg);
+     }
+ 
+     /** Displays a success message in green in the login form label. */
+     private void showSuccess(String msg) {
+         labelErrore.setTextFill(Color.web("#6fcf8a"));
+         labelErrore.setText(msg);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-5.html new file mode 100644 index 0000000..0e4481e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-5.html @@ -0,0 +1,902 @@ + + + + + + + + Coverage Report > MainFXMLController + + + + + + +
+ + +

Coverage Summary for Class: MainFXMLController (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
MainFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/50) + + + + 0% + + + (0/124) + + + + 0% + + + (0/426) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.Model.*;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import javafx.animation.ScaleTransition;
+ import javafx.animation.TranslateTransition;
+ import javafx.application.Platform;
+ import javafx.beans.value.ChangeListener;
+ import javafx.beans.value.ObservableValue;
+ import javafx.event.Event;
+ import javafx.fxml.FXML;
+ import javafx.geometry.Bounds;
+ import javafx.geometry.Insets;
+ import javafx.geometry.Pos;
+ import javafx.geometry.Rectangle2D;
+ import javafx.scene.Cursor;
+ import javafx.scene.Node;
+ import javafx.scene.Scene;
+ import javafx.scene.control.Button;
+ import javafx.scene.control.Label;
+ import javafx.scene.control.ScrollPane;
+ import javafx.scene.effect.ColorAdjust;
+ import javafx.scene.effect.DropShadow;
+ import javafx.scene.image.*;
+ import javafx.scene.input.MouseEvent;
+ import javafx.scene.layout.*;
+ import javafx.scene.paint.Color;
+ import javafx.scene.shape.*;
+ import javafx.scene.text.Font;
+ import javafx.stage.Popup;
+ import javafx.stage.Screen;
+ import javafx.stage.Window;
+ import javafx.util.Duration;
+ 
+ import java.util.*;
+ 
+ /**
+  * FXML controller for the main game scene.
+  *
+  * <p>Renders the board (upper/lower tribe and building card rows), player stats,
+  * the player's hand, and action buttons (skip, details).
+  */
+ public class MainFXMLController {
+     //TODO
+     @FXML private GridPane leftGrid;
+     //TODO
+     @FXML private ScrollPane playerSide;
+     //TODO
+     @FXML private HBox mainHBox;
+     //TODO
+     @FXML private ImageView backgroundImage;
+     //TODO
+     @FXML private HBox board;
+     //TODO
+     @FXML private HBox upperList;
+     //TODO
+     @FXML private HBox lowerList;
+     //TODO
+     @FXML private HBox myHand;
+     //TODO
+     @FXML private Button skipBtn;
+     //TODO
+     @FXML private Button detailsBtn;
+     //TODO
+     @FXML private Label infoText;
+     //TODO
+     private final Map<String, Label> foodLabels     = new HashMap<>();
+     //TODO
+     private final Map<String, Label> prestigeLabels = new HashMap<>();
+     //TODO
+     private final Map<String, VBox>  playerCards    = new HashMap<>();
+     //TODO
+     private final Map<String, List<ImageView>> iconViews = new HashMap<>();
+     //TODO
+     private Popup popup;
+     //TODO
+     private HBox popupCards;
+     //TODO
+     private ClientController controller;
+ 
+     /** {@code true} when the last received event was an error response. */
+     private boolean isError;
+ 
+     /** Sets the error flag; called by {@link GUI} before delegating to {@link #render()}. */
+     public void setError(boolean error) { this.isError = error; }
+ 
+     // ==== IMAGE CACHE ====
+     private static final Map<String, Image> imageCache = new HashMap<>();
+ 
+     /** Returns a cached {@link Image} for the given classpath {@code path}, loading it on first access. */
+     private Image loadImage(String path) {
+         return imageCache.computeIfAbsent(path,
+                 p -> new Image(getClass().getResourceAsStream(p)));
+     }
+ 
+     /**
+      * Injects the client controller and wires up the skip-turn button action.
+      *
+      * @param controller the client controller to use.
+      */
+     public void setController(ClientController controller) {
+         this.controller = controller;
+         skipBtn.setOnAction(e -> controller.skipTurn());
+     }
+ 
+     /** Initializes the scene: loads fonts, sets up the popup, and registers input listeners. */
+     @FXML
+     public void initialize() {
+         Font.loadFont(getClass().getResourceAsStream("/Fonts/InknutAntiqua-Regular.ttf"), 14);
+ 
+         addHoverZoom(skipBtn);
+         addHoverZoom(detailsBtn);
+         popup = new Popup();
+         mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> {
+             if (newScene != null) {
+                 newScene.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> {
+                     if (popup.isShowing()) popup.hide();
+                 });
+                 newScene.getRoot().applyCss();
+                 newScene.windowProperty().addListener((o2, ow, nw) -> {
+                     if (nw != null) {
+                         nw.focusedProperty().addListener((o3, wf, nf) -> {
+                             if (!nf) popup.hide();
+                         });
+                     }
+                 });
+             }
+             else {
+                 popup.hide();
+             }
+         });
+         initPopup();
+         detailsBtn.setOnAction(e -> openDetailsPopup());
+         renderBackground();
+         isError=false;
+     }
+ 
+ 
+     // ==== RENDER ====
+     /** Incrementally re-renders only the parts of the scene affected by the last network event. */
+     public void render() {
+         if(foodLabels.isEmpty() || controller.getMiniModel().lastEvent == null
+                 || controller.getMiniModel().lastEvent.getEventType().equals(EventType.TOTEM_CHOICE))
+             buildSidePanel();
+         if(isError)
+         {
+             updateSidePanel();
+             isError=false;
+             return;
+         }
+         if(controller.getMiniModel().lastEvent==null ||controller.getMiniModel().lastEvent.getEventType().equals(EventType.TOTEM_CHOICE) || controller.getMiniModel().lastEvent.getEventType().equals(EventType.NEXT_ROUND)) {
+             renderMyHand();
+             renderUpper();
+             renderBoard();
+             renderLower();
+             updateSidePanel();
+             return;
+         }
+         if(controller.getMiniModel().lastEvent.getEventType().equals(EventType.DRAW_UPPER_TRIBE) || controller.getMiniModel().lastEvent.getEventType().equals(EventType.DRAW_UPPER_BUILD))
+         {
+             renderUpper();
+         }
+         if(controller.getMiniModel().lastEvent.getEventType().equals(EventType.DRAW_LOWER_TRIBE) || controller.getMiniModel().lastEvent.getEventType().equals(EventType.DRAW_LOWER_BUILD))
+         {
+             renderLower();
+         }
+         if(controller.getMiniModel().lastEvent.getUsername().equals(controller.getMyUsername()))
+         {
+             renderMyHand();
+         }
+         renderBoard();
+         updateSidePanel();
+     }
+ 
+ 
+     // ==== EFFECTS ====
+     /** Binds a rounded-rectangle clip to {@code img} so its corners are cropped. */
+     private void addClip(ImageView img) {
+         Rectangle clip = new Rectangle();
+         clip.setArcWidth(20);
+         clip.setArcHeight(20);
+         img.setClip(clip);
+         clip.heightProperty().bind(img.layoutBoundsProperty().map(b -> b.getHeight()));
+         clip.widthProperty().bind(img.layoutBoundsProperty().map(b -> b.getWidth()));
+     }
+ 
+     /** Scales {@code node} to 1.1× on hover and restores on exit; sets a hand cursor. */
+     private void addHoverZoom(Node node) {
+         ScaleTransition scaleUp = new ScaleTransition(Duration.millis(150), node);
+         scaleUp.setToX(1.1);
+         scaleUp.setToY(1.1);
+         ScaleTransition scaleDown = new ScaleTransition(Duration.millis(150), node);
+         scaleDown.setToX(1.0);
+         scaleDown.setToY(1.0);
+         node.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> { scaleUp.play(); node.setCursor(Cursor.HAND); });
+         node.addEventHandler(MouseEvent.MOUSE_EXITED,  e -> { scaleDown.play(); node.setCursor(Cursor.DEFAULT); });
+     }
+ 
+     /** Applies a drop-shadow to {@code node} that intensifies on hover. */
+     private void addShadow(Node node) {
+         DropShadow shadow = new DropShadow();
+         shadow.setColor(Color.rgb(0, 0, 0, 0.3));
+         shadow.setRadius(6);
+         shadow.setOffsetX(2);
+         shadow.setOffsetY(2);
+         node.setEffect(shadow);
+         node.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> {
+             shadow.setRadius(16);
+             shadow.setOffsetX(4);
+             shadow.setOffsetY(4);
+             shadow.setColor(Color.rgb(0, 0, 0, 0.5));
+         });
+         node.addEventHandler(MouseEvent.MOUSE_EXITED, e -> {
+             shadow.setRadius(6);
+             shadow.setOffsetX(2);
+             shadow.setOffsetY(2);
+             shadow.setColor(Color.rgb(0, 0, 0, 0.3));
+         });
+     }
+ 
+ 
+     // ==== ELEMENTS ====
+ 
+     /** Builds the side-panel card widget for {@code player} with totem, stats, and card-type icons. */
+     private VBox buildPlayerCard(Player player) {
+         VBox card = new VBox(3);
+         VBox.setMargin(card, new Insets(15, 15, 0, 15));
+         card.getStyleClass().add("player-card");
+         card.setPadding(new Insets(4));
+ 
+         HBox headerRow = new HBox(8);
+         headerRow.setAlignment(Pos.CENTER);
+         ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_"
+                 + player.getTotem().toString().toLowerCase(Locale.ROOT) + ".png"));
+         totem.setFitHeight(20);
+         totem.setPreserveRatio(true);
+         Label usernameLabel = new Label(player.getUserName());
+         usernameLabel.getStyleClass().add("label-medium");
+         usernameLabel.setStyle("-fx-text-fill: #711423;");
+         if (player.getUserName().equals(controller.getMyUsername())) {
+             usernameLabel.setText(usernameLabel.getText() + " (you)");
+         }
+         if (controller.getMiniModel().disconnectedPlayers.contains(player.getUserName())) {
+             card.getStyleClass().add("player-card-crashed");
+         }
+         headerRow.getChildren().addAll(totem, usernameLabel);
+ 
+         HBox statsRow = new HBox(10);
+         statsRow.setAlignment(Pos.CENTER);
+ 
+         HBox foodBox = new HBox(4);
+         foodBox.setAlignment(Pos.CENTER);
+         ImageView foodIcon = new ImageView(loadImage("/GUIImages/Icons/Food.png"));
+         foodIcon.setFitHeight(20);
+         foodIcon.setPreserveRatio(true);
+         Label foodLabel = new Label(String.valueOf(player.getFoodValue()));
+         foodLabel.getStyleClass().add("label-small");
+         foodLabels.put(player.getUserName(), foodLabel);
+         foodBox.getChildren().addAll(foodIcon, foodLabel);
+ 
+         HBox prestigeBox = new HBox(1);
+         prestigeBox.setAlignment(Pos.CENTER);
+         ImageView ppIcon = new ImageView(loadImage("/GUIImages/Icons/PrestigePoint.png"));
+         ppIcon.setFitHeight(35);
+         ppIcon.setPreserveRatio(true);
+         Label prestigeLabel = new Label(String.valueOf(player.getPrestigeValue()));
+         prestigeLabel.getStyleClass().add("label-small");
+         prestigeLabels.put(player.getUserName(), prestigeLabel);
+         prestigeBox.getChildren().addAll(ppIcon, prestigeLabel);
+ 
+         ImageView buildingIcon = new ImageView(loadImage("/GUIImages/Icons/Building.png"));
+         buildingIcon.setFitWidth(28);
+         buildingIcon.setFitHeight(28);
+         buildingIcon.setPreserveRatio(true);
+         buildingIcon.setOnMouseClicked(e -> {
+             ArrayList<PlayableCard> cards = getPlayerCards(player.getUserName(), "building");
+             if (!cards.isEmpty()) openPopup(cards);
+         });
+         addHoverZoom(buildingIcon);
+ 
+         statsRow.getChildren().addAll(foodBox, prestigeBox, buildingIcon);
+ 
+         HBox iconsRow1 = new HBox(6);
+         iconsRow1.setSpacing(20);
+         iconsRow1.setAlignment(Pos.CENTER);
+         HBox iconsRow2 = new HBox(6);
+         iconsRow2.setAlignment(Pos.CENTER);
+         iconsRow2.setSpacing(20);
+ 
+         String[][] iconTypes = {
+                 {"Artist",   "artists"},
+                 {"Gatherer", "gatherers"},
+                 {"Inventor", "inventors"},
+                 {"Builder",  "builders"},
+                 {"Shaman",   "shamans"},
+                 {"Hunter",   "hunters"}
+         };
+ 
+         List<ImageView> icons = new ArrayList<>();
+         // building must be index 0; updateSidePanel iterates icons in ["building","artists",...] order
+         icons.add(buildingIcon);
+ 
+         for (int i = 0; i < iconTypes.length; i++) {
+             String iconName  = iconTypes[i][0];
+             String fieldName = iconTypes[i][1];
+ 
+             ImageView icon = new ImageView(loadImage("/GUIImages/Icons/" + iconName + ".png"));
+             icon.setFitWidth(28);
+             icon.setFitHeight(28);
+             icon.setPreserveRatio(true);
+             icon.setOnMouseClicked(e -> {
+                 ArrayList<PlayableCard> cards = getPlayerCards(player.getUserName(), fieldName);
+                 if (!cards.isEmpty()) openPopup(cards);
+             });
+             addHoverZoom(icon);
+             icons.add(icon);
+ 
+             if (i < 3) iconsRow1.getChildren().add(icon);
+             else       iconsRow2.getChildren().add(icon);
+         }
+ 
+         iconViews.put(player.getUserName(), icons);
+ 
+         card.getChildren().addAll(headerRow, statsRow, iconsRow1, iconsRow2);
+         return card;
+     }
+ 
+     /** Creates a {@link StackPane} containing the order card image for a game of {@code num} players. */
+     private StackPane createOrder(String num) {
+         ImageView img = new ImageView(loadImage("/GUIImages/Orders/order-" + num + ".png"));
+         img.fitHeightProperty().bind(board.sceneProperty().get().heightProperty().subtract(56).divide(4).multiply(0.94));
+         img.setPreserveRatio(true);
+         addClip(img);
+         return new StackPane(img);
+     }
+ 
+     /** Creates a {@link StackPane} for a board slot, optionally overlaying the occupying player's totem. */
+     private StackPane createSlot(Slot slot, boolean withZoom, boolean withShadow) {
+         ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + slot.getSlotId() + ".png"));
+         img.setPreserveRatio(true);
+         img.fitHeightProperty().bind(board.sceneProperty().get().heightProperty().subtract(56).divide(4).multiply(0.94));
+         addClip(img);
+         StackPane wrapper = new StackPane(img);
+ 
+         Player player = controller.getMiniModel().slotPlayerMap.get(slot);
+         if (player != null && controller.getMiniModel().getPositionByUsername(player.getUserName()) != -1) {
+             ImageView totem = new ImageView(loadImage("/GUIImages/Totems/totem_" + player.getTotem().toString().toLowerCase(Locale.ROOT) + ".png"));
+             totem.fitHeightProperty().bind(img.fitHeightProperty().multiply(0.332));
+             totem.setPreserveRatio(true);
+             StackPane.setAlignment(totem, Pos.TOP_LEFT);
+             img.fitHeightProperty().addListener((obs, ov, nv) -> {
+                 StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * nv.doubleValue()));
+             });
+             if (img.getFitHeight() > 0) {
+                 StackPane.setMargin(totem, new Insets(0, 0, 0, 0.224 * img.getFitHeight()));
+             }
+             wrapper.getChildren().add(totem);
+         }
+ 
+         if (withShadow) addShadow(wrapper);
+         if (withZoom)   addHoverZoom(wrapper);
+         return wrapper;
+     }
+ 
+     /** Creates a {@link StackPane} for a playable card, scaling its height to a fraction of {@code parent}'s scene. */
+     private StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow, Region parent) {
+         ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
+         img.setPreserveRatio(true);
+         if(controller.getMiniModel().players.size()==5)
+         {
+             img.fitHeightProperty().bind(parent.getScene().heightProperty().subtract(56).divide(4).multiply(0.85));
+         }
+         else
+             img.fitHeightProperty().bind(parent.getScene().heightProperty().subtract(56).divide(4).multiply(0.90));
+         addClip(img);
+         StackPane wrapper = new StackPane(img);
+         if (withShadow) addShadow(wrapper);
+         if (withZoom)   addHoverZoom(wrapper);
+         return wrapper;
+     }
+ 
+ 
+ 
+     // ==== GROUPS ====
+     /** Builds the full side panel from scratch, creating a player card for each connected player. */
+     private void buildSidePanel() {
+         infoText.setText("Round: "+Integer.toString(controller.getMiniModel().currentState.getRound()) + " • " + controller.getMiniModel().currentState.getGameStage().toString());
+         VBox playerList = new VBox();
+         playerList.setFillWidth(true);
+         for (Player p : controller.getMiniModel().players.values()) {
+             VBox card = buildPlayerCard(p);
+             playerCards.put(p.getUserName(), card);
+             playerList.getChildren().add(card);
+         }
+         playerSide.setContent(playerList);
+     }
+ 
+     /** Updates food/prestige labels, current-player highlight, card-icon opacity, and plays error shake if needed. */
+     private void updateSidePanel() {
+         infoText.setText("Round: "+Integer.toString(controller.getMiniModel().currentState.getRound()) + " • " + controller.getMiniModel().currentState.getGameStage().toString());
+         if (controller.getMiniModel().currentState.getCurrentPlayer() == null) return;
+         String current = controller.getMiniModel().currentState.getCurrentPlayer().getUserName();
+         // ordine: building, artists, gatherers, inventors, builders, shamans, hunters
+         String[] fields = {"building", "artists", "gatherers", "inventors", "builders", "shamans", "hunters"};
+ 
+         for (Player p : controller.getMiniModel().players.values()) {
+             String u = p.getUserName();
+ 
+             foodLabels.get(u).setText(String.valueOf(p.getFoodValue()));
+             prestigeLabels.get(u).setText(String.valueOf(p.getPrestigeValue()));
+ 
+             List<ImageView> icons = iconViews.get(u);
+             for (int i = 0; i < icons.size(); i++) {
+                 boolean empty = getPlayerCards(u, fields[i]).isEmpty();
+                 icons.get(i).setOpacity(empty ? 0.3 : 1.0);
+                 icons.get(i).setEffect(empty ? new ColorAdjust() : null);
+             }
+ 
+             VBox card = playerCards.get(u);
+             if(controller.getMiniModel().disconnectedPlayers.contains(u))
+             {
+                 card.getStyleClass().clear();
+                 card.getStyleClass().add("player-card-crashed");
+             }
+             else {
+                 card.getStyleClass().clear();
+                 card.getStyleClass().add("player-card");
+             }
+ 
+             if (u.equals(current)) {
+                 card.setStyle("-fx-effect: dropshadow(gaussian, #fff8dc, 15, 0.10, 0, 0)");
+                 ScaleTransition st = new ScaleTransition(Duration.millis(150), card);
+                 st.setToX(1.1);
+                 st.setToY(1.1);
+                 st.play();
+             } else {
+                 ScaleTransition st = new ScaleTransition(Duration.millis(150), card);
+                 st.setToX(1.0);
+                 st.setToY(1.0);
+                 st.play();
+                 card.setStyle("");
+             }
+ 
+             if (isError && u.equals(controller.getMyUsername())) {
+                 TranslateTransition tt = new TranslateTransition(Duration.millis(56), card);
+                 tt.setFromX(0);
+                 tt.setByX(10);
+                 tt.setCycleCount(6);
+                 tt.setAutoReverse(true);
+                 tt.play();
+             }
+         }
+     }
+ 
+     /** Renders the top card of the upper building stack with a count badge; clicking opens the selection popup. */
+     private void drawUpperBuilding() {
+         ArrayList<BuildingCard> cardList = new ArrayList<>(controller.getMiniModel().upperListBuildingCards);
+         if (!cardList.isEmpty()) {
+             StackPane img = createCard(cardList.getLast(), true, true, upperList);
+             Label label = new Label(String.valueOf(cardList.size()));
+             label.setTranslateY(-56);
+             label.setTranslateX(10);
+             label.getStyleClass().add("label-large");
+             StackPane.setAlignment(label, Pos.TOP_RIGHT);
+             img.getChildren().add(label);
+             img.setOnMouseClicked(e -> openPopupUpperBuilding(cardList));
+             upperList.getChildren().add(img);
+         }
+     }
+ 
+     /** Renders the top card of the lower building stack with a count badge; clicking opens the selection popup. */
+     private void drawLowerBuilding() {
+         ArrayList<BuildingCard> cardList = new ArrayList<>(controller.getMiniModel().lowerListBuildingCards);
+         if (!cardList.isEmpty()) {
+             StackPane img = createCard(cardList.getLast(), true, true, lowerList);
+             Label label = new Label(String.valueOf(cardList.size()));
+             label.setTranslateY(-56);
+             label.setTranslateX(10);
+             label.getStyleClass().add("label-large");
+             StackPane.setAlignment(label, Pos.TOP_RIGHT);
+             img.getChildren().add(label);
+             img.setOnMouseClicked(e -> openPopupLowerBuilding(cardList));
+             lowerList.getChildren().add(img);
+         }
+     }
+ 
+     /** Renders a single card-type pile in the hand area, or an invisible placeholder if the list is empty. */
+     private void drawMyHandList(ArrayList<? extends PlayableCard> cardList) {
+         if (!cardList.isEmpty()) {
+             StackPane img = createCard(cardList.getLast(), true, true, myHand);
+             Label label = new Label(String.valueOf(cardList.size()));
+             label.setTranslateY(-56);
+             label.setTranslateX(10);
+             label.getStyleClass().add("label-large");
+             StackPane.setAlignment(label, Pos.TOP_RIGHT);
+             img.getChildren().add(label);
+             img.setOnMouseClicked(e -> openPopup(new ArrayList<>(cardList)));
+             myHand.getChildren().add(img);
+         } else {
+             Region placeholder = new Region();
+             placeholder.prefHeightProperty().bind(myHand.getScene().heightProperty().subtract(56).divide(4).multiply(0.90));
+             placeholder.prefWidthProperty().bind(placeholder.prefHeightProperty().multiply(0.675));
+             placeholder.setStyle("-fx-background-color: transparent;");
+             myHand.getChildren().add(placeholder);
+         }
+     }
+ 
+     /** Returns a copy of the named card collection for {@code username}. */
+     private ArrayList<PlayableCard> getPlayerCards(String username, String type) {
+         Player p = controller.getMiniModel().players.get(username);
+         return switch (type) {
+             case "artists"   -> new ArrayList<>(p.getArtists());
+             case "gatherers" -> new ArrayList<>(p.getGatherers());
+             case "inventors" -> new ArrayList<>(p.getInventors());
+             case "builders"  -> new ArrayList<>(p.getBuilders());
+             case "shamans"   -> new ArrayList<>(p.getShamans());
+             case "hunters"   -> new ArrayList<>(p.getHunters());
+             case "building"  -> new ArrayList<>(p.getBuildingCards());
+             default          -> new ArrayList<>();
+         };
+     }
+ 
+ 
+     // ==== ABSOLUTES ====
+     /** Clears and rebuilds the upper tribe row with click handlers for drawing, then appends the upper building stack. */
+     private void renderUpper() {
+         upperList.setSpacing(14);
+         upperList.setAlignment(Pos.CENTER);
+         upperList.getChildren().clear();
+ 
+         int i = 0;
+         for (TribeCard card : controller.getMiniModel().upperListTribeCards) {
+             final int index = i;
+             StackPane img = createCard(card, true, true, upperList);
+             img.setOnMouseClicked(e -> controller.drawUpperTribeCard(index));
+             upperList.getChildren().add(img);
+             i++;
+         }
+         drawUpperBuilding();
+     }
+ 
+     /** Clears and rebuilds the lower tribe row with click handlers for drawing, then appends the lower building stack. */
+     private void renderLower() {
+         lowerList.setSpacing(14);
+         lowerList.setAlignment(Pos.CENTER);
+         lowerList.getChildren().clear();
+ 
+         int i = 0;
+         for (TribeCard card : controller.getMiniModel().lowerListTribeCards) {
+             final int index = i;
+             StackPane img = createCard(card, true, true, lowerList);
+             img.setOnMouseClicked(e -> controller.drawLowerTribeCard(index));
+             lowerList.getChildren().add(img);
+             i++;
+         }
+         drawLowerBuilding();
+     }
+ 
+     /** Sets the full-cover background image on the main HBox container. */
+     private void renderBackground() {
+         BackgroundSize size = new BackgroundSize(
+                 BackgroundSize.AUTO, BackgroundSize.AUTO,
+                 false, false, true, true
+         );
+         mainHBox.setBackground(new Background(new BackgroundImage(
+                 loadImage("/GUIImages/Background.png"),
+                 BackgroundRepeat.NO_REPEAT,
+                 BackgroundRepeat.NO_REPEAT,
+                 BackgroundPosition.CENTER,
+                 size
+         )));
+     }
+ 
+     /** Clears the board area and orchestrates deck, order card, and slot-map rendering. */
+     private void renderBoard() {
+         board.setSpacing(14);
+         board.setAlignment(Pos.CENTER);
+         board.getChildren().clear();
+         renderDeck();
+         renderOrder();
+         renderSlotMap();
+     }
+ 
+     /** Adds the era-specific deck back image to the board. */
+     private void renderDeck() {
+         String path = switch (controller.getMiniModel().currentState.getEra()) {
+             case 1  -> "/GUIImages/Backs/back-001.png";
+             case 2  -> "/GUIImages/Backs/back-030.png";
+             case 3  -> "/GUIImages/Backs/back-058.png";
+             default -> "/GUIImages/Backs/back-001.png";
+         };
+         ImageView back = new ImageView(loadImage(path));
+         back.fitHeightProperty().bind(board.sceneProperty().get().heightProperty().subtract(56).divide(4).multiply(0.94));
+         back.setPreserveRatio(true);
+         addClip(back);
+         addShadow(back);
+         addHoverZoom(back);
+         board.getChildren().add(back);
+     }
+ 
+     /** Renders the order card and overlays each player's totem at their proportional position. */
+     private void renderOrder() {
+         int numPlayers = controller.getMiniModel().players.size();
+         StackPane card = createOrder(Integer.toString(numPlayers));
+ 
+         Map<Integer, double[]> slotPositions = Map.of(
+                 2, new double[]{0.229, 0.413},
+                 3, new double[]{0.183, 0.367, 0.548},
+                 4, new double[]{0.142, 0.316, 0.503, 0.690},
+                 5, new double[]{0.066, 0.251, 0.433, 0.617, 0.802}
+         );
+         double[] positions = slotPositions.get(numPlayers);
+         if (positions == null) return;
+ 
+         Pane overlay = new Pane();
+         overlay.setPickOnBounds(false);
+         overlay.setMouseTransparent(true);
+ 
+         for (int i = 0; i < controller.getMiniModel().orderLogicCard.getPlayerList().size(); i++) {
+             OrderPlayer op = controller.getMiniModel().orderLogicCard.getPlayerList().get(i);
+ 
+             ImageView totem = new ImageView(loadImage(
+                     "/GUIImages/Totems/totem_" + op.getPlayer().getTotem().toString().toLowerCase(Locale.ROOT) + ".png"
+             ));
+             totem.setPreserveRatio(true);
+ 
+             if (op.isPlayed()) {
+                 totem.setVisible(false);
+             }
+ 
+             final double yRatio = positions[i];
+ 
+             overlay.prefHeightProperty().bind(card.heightProperty());
+             overlay.prefWidthProperty().bind(card.widthProperty());
+ 
+             totem.fitHeightProperty().bind(card.heightProperty().multiply(0.323));
+ 
+             card.heightProperty().addListener((obs, ov, nv) -> {
+                 totem.setLayoutY(nv.doubleValue() * (yRatio-0.196));
+             });
+             card.widthProperty().addListener((obs, ov, nv) -> {
+                 totem.setLayoutX(nv.doubleValue() * 0.364);
+             });
+ 
+             // initialize immediately if already laid out
+             if (card.getHeight() > 0) totem.setLayoutY(card.getHeight() *(yRatio-0.196));
+             if (card.getWidth() > 0)  totem.setLayoutX(card.getWidth() * 0.364);
+ 
+             overlay.getChildren().add(totem);
+         }
+ 
+         card.getChildren().add(overlay);
+         board.getChildren().add(card);
+     }
+ 
+     /** Adds a clickable slot widget for each entry in the slot-player map. */
+     private void renderSlotMap() {
+         int i = 0;
+         for (Map.Entry<Slot, Player> entry : controller.getMiniModel().slotPlayerMap.entrySet()) {
+             Slot slot = entry.getKey();
+             final int index = i;
+             StackPane img = createSlot(slot, true, true);
+             img.setOnMouseClicked(e -> controller.slotChoice(index));
+             board.getChildren().add(img);
+             i++;
+         }
+     }
+ 
+     /** Clears and re-renders all seven card-type piles in the local player's hand area. */
+     private void renderMyHand() {
+         myHand.getChildren().clear();
+         myHand.setSpacing(14);
+         myHand.setAlignment(Pos.CENTER);
+ 
+         Player me = controller.getMiniModel().players.get(controller.getMyUsername());
+         drawMyHandList(me.getArtists());
+         drawMyHandList(me.getGatherers());
+         drawMyHandList(me.getInventors());
+         drawMyHandList(me.getBuilders());
+         drawMyHandList(me.getShamans());
+         drawMyHandList(me.getHunters());
+         drawMyHandList(me.getBuildingCards());
+     }
+ 
+ 
+     // ==== POPUP ====
+     /** Creates and configures the shared card-preview popup container. */
+     private void initPopup() {
+         popupCards = new HBox(10);
+         popupCards.setAlignment(Pos.CENTER);
+         popupCards.setPadding(new Insets(10));
+         popupCards.setStyle(
+                 "-fx-background-color: #b42224;" +
+                         "-fx-border-color: black;" +
+                         "-fx-border-width: 2;" +
+                         "-fx-border-radius: 10;" +
+                         "-fx-background-radius: 10;"
+         );
+ 
+         popup.getContent().add(popupCards);
+         popup.setAutoHide(false);
+         popup.addEventHandler(Event.ANY, e -> {
+             if (popup.getScene() != null) {
+                 popup.getScene().setFill(Color.TRANSPARENT);
+             }
+         });
+     }
+ 
+     /** Centers the popup over the current window and makes it visible. */
+     private void showPopup() {
+         Window window = myHand.getScene().getWindow();
+         popup.show(window, 0, 0);
+         popup.getScene().setFill(Color.TRANSPARENT);
+         popup.setX(window.getX() + (window.getWidth()  - popup.getWidth())  / 2);
+         popup.setY(window.getY() + (window.getHeight() - popup.getHeight()) / 2);
+     }
+ 
+     /** Populates the popup with non-clickable card images and shows it. */
+     private void openPopup(ArrayList<? extends PlayableCard> cardList) {
+         popupCards.getChildren().clear();
+         for (PlayableCard card : cardList) {
+             popupCards.getChildren().add(createCardPopup(card, false, false));
+         }
+         showPopup();
+     }
+ 
+     /** Populates the popup with clickable upper-building cards; clicking one draws it via the controller. */
+     private void openPopupUpperBuilding(ArrayList<BuildingCard> cardList) {
+         popupCards.getChildren().clear();
+         for (int i = 0; i < cardList.size(); i++) {
+             final int index = i;
+             StackPane img = createCardPopup(cardList.get(i), true, false);
+             img.setOnMouseClicked(e -> {
+                 popup.hide();
+                 controller.drawUpperBuildingCard(index);
+             });
+             popupCards.getChildren().add(img);
+         }
+         showPopup();
+     }
+ 
+     /** Populates the popup with clickable lower-building cards; clicking one draws it via the controller. */
+     private void openPopupLowerBuilding(ArrayList<BuildingCard> cardList) {
+         popupCards.getChildren().clear();
+         for (int i = 0; i < cardList.size(); i++) {
+             final int index = i;
+             StackPane img = createCardPopup(cardList.get(i), true, false);
+             img.setOnMouseClicked(e -> {
+                 popup.hide();
+                 controller.drawLowerBuildingCard(index);
+             });
+             popupCards.getChildren().add(img);
+         }
+         showPopup();
+     }
+ 
+     /** Shows the deck details/rules card in the popup. */
+     private void openDetailsPopup() {
+         popupCards.getChildren().clear();
+         ImageView img = new ImageView(loadImage("/GUIImages/Backs/back-118.png"));
+         img.setFitHeight(290);
+         img.setPreserveRatio(true);
+         addClip(img);
+         StackPane wrapper = new StackPane(img);
+         addShadow(wrapper);
+         popupCards.getChildren().add(wrapper);
+         showPopup();
+     }
+ 
+     /** Creates a fixed-height {@link StackPane} card widget suitable for use inside the popup. */
+     private StackPane createCardPopup(PlayableCard card, boolean withZoom, boolean withShadow) {
+         ImageView img = new ImageView(loadImage("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png"));
+         img.setFitHeight(200);
+         img.setPreserveRatio(true);
+         addClip(img);
+         StackPane wrapper = new StackPane(img);
+         if (withShadow) addShadow(wrapper);
+         if (withZoom)   addHoverZoom(wrapper);
+         return wrapper;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-12/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-12/sources/source-6.html new file mode 100644 index 0000000..1582b47 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-12/sources/source-6.html @@ -0,0 +1,345 @@ + + + + + + + + Coverage Report > TotemFXMLController + + + + + + +
+ + +

Coverage Summary for Class: TotemFXMLController (it.polimi.ingsw.gc14.View.GUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemFXMLController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/24) + + + + 0% + + + (0/90) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.GUI;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.Model.Totems;
+ import javafx.animation.*;
+ import javafx.fxml.FXML;
+ import javafx.geometry.Pos;
+ import javafx.geometry.Rectangle2D;
+ import javafx.scene.Cursor;
+ import javafx.scene.control.Button;
+ import javafx.scene.control.Label;
+ import javafx.scene.image.Image;
+ import javafx.scene.image.ImageView;
+ import javafx.scene.layout.*;
+ import javafx.stage.Screen;
+ import javafx.util.Duration;
+ 
+ import java.util.Locale;
+ 
+ /**
+  * FXML controller for the totem selection scene.
+  *
+  * <p>Displays the available totems and lets the current player choose one;
+  * other players see a waiting banner.
+  */
+ public class TotemFXMLController {
+     //TODO
+     @FXML private ImageView backgroundImage;
+     //TODO
+     @FXML private HBox mainHBox;
+     //TODO
+     @FXML private Label turnBanner;
+     //TODO
+     @FXML private Button confirmButton;
+ 
+     //TODO
+     private ClientController controller;
+     //TODO
+     private int selectedIndex = -1;
+     //TODO
+     private StackPane selectedFrame = null;
+ 
+     /**
+      * Injects the client controller into this FXML controller.
+      *
+      * @param controller the client controller to use.
+      */
+     public void setController(ClientController controller) {
+         this.controller = controller;
+     }
+ 
+     /** Initializes the scene: sets the background image to fill the screen. */
+     @FXML
+     public void initialize() {
+         Image img = new Image(getClass().getResourceAsStream("/GUIImages/Background.png"));
+         backgroundImage.setImage(img);
+         Rectangle2D screenBounds = Screen.getPrimary().getBounds();
+         backgroundImage.setFitWidth(screenBounds.getWidth());
+         backgroundImage.setFitHeight(screenBounds.getHeight());
+     }
+ 
+     /**
+      * Renders the totem selection cards with entry animations.
+      * Disables interaction for players who are not the current chooser.
+      */
+     public void render() {
+         mainHBox.getChildren().clear();
+         selectedIndex = -1;
+         selectedFrame = null;
+ 
+         if (controller.getMiniModel().currentState.getCurrentPlayer() == null) return;
+         String chooser = controller.getMiniModel().currentState.getCurrentPlayer().getUserName();
+         boolean myTurn = chooser.equals(controller.getMyUsername());
+ 
+         updateBanner(chooser, myTurn);
+         updateConfirmButton(false);
+ 
+         for (int i = 0; i < controller.getMiniModel().availableTotems.size(); i++) {
+             Totems totem = controller.getMiniModel().availableTotems.get(i);
+             VBox card = buildCard(totem, i, myTurn);
+             mainHBox.getChildren().add(card);
+ 
+             card.setOpacity(0);
+             card.setTranslateY(14);
+             PauseTransition delay = new PauseTransition(Duration.millis(80 + i * 65));
+             delay.setOnFinished(e -> {
+                 FadeTransition ft = new FadeTransition(Duration.millis(320), card);
+                 ft.setToValue(1);
+                 TranslateTransition tt = new TranslateTransition(Duration.millis(320), card);
+                 tt.setToY(0);
+                 new ParallelTransition(ft, tt).play();
+             });
+             delay.play();
+         }
+     }
+ 
+     /** Updates the turn banner text and style based on whether it is the local player's turn. */
+     private void updateBanner(String chooser, boolean myTurn) {
+         if (myTurn) {
+             turnBanner.setText("✦   It's your turn to choose   ✦");
+             turnBanner.setStyle(
+                     "-fx-font-family: 'Cinzel'; -fx-font-size: 13; -fx-font-weight: 'bold'; -fx-letter-spacing: 3;" +
+                             "-fx-text-fill: #000000;" +
+                             "-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
+                             "-fx-border-color: #000000; -fx-border-width: 1;" +
+                             "-fx-border-radius: 3; -fx-background-radius: 3;" +
+                             "-fx-padding: 10 28 10 28;" +
+                             "-fx-effect: dropshadow(gaussian, rgba(244,192,90,0.3), 18, 0, 0, 0);"
+             );
+         } else {
+             turnBanner.setText("Waiting for " + chooser + " to choose his totem…");
+             turnBanner.setStyle(
+                     "-fx-font-family: 'Cinzel'; -fx-font-size: 11; -fx-letter-spacing: 2;" +
+                             "-fx-text-fill:  #000000;" +
+                             "-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
+                             "-fx-border-color:  #000000; -fx-border-width: 1;" +
+                             "-fx-border-radius: 3; -fx-background-radius: 3;" +
+                             "-fx-padding: 10 28 10 28;"
+             );
+         }
+     }
+ 
+     /** Builds a totem card widget; if {@code interactive}, wires click/hover handlers and selection logic. */
+     private VBox buildCard(Totems totem, int idx, boolean interactive) {
+         ImageView img = new ImageView(new Image(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + String.valueOf(totem).toLowerCase(Locale.ROOT) + ".png")));
+         img.setFitHeight(150);
+         img.setPreserveRatio(true);
+ 
+         StackPane frame = new StackPane(img);
+         frame.setPrefSize(100, 145);
+         frame.setBackground(Background.EMPTY);
+         img.setStyle(frameStyle(false));
+ 
+         Region base = new Region();
+         base.setPrefSize(100, 10);
+ 
+         Label name = new Label(capitalize(totem));
+         name.setStyle(nameStyle(false));
+ 
+         VBox card = new VBox(4, frame, base, name);
+         card.setAlignment(Pos.CENTER);
+ 
+         if (!interactive) {
+             card.setOpacity(0.35);
+             card.setCursor(Cursor.DEFAULT);
+             return card;
+         }
+ 
+         card.setCursor(Cursor.HAND);
+ 
+         card.setOnMouseEntered(e -> {
+             if (frame != selectedFrame) {
+                 ScaleTransition st = new ScaleTransition(Duration.millis(140), card);
+                 st.setToX(1.06); st.setToY(1.06); st.play();
+             }
+         });
+         card.setOnMouseExited(e -> {
+             if (frame != selectedFrame) {
+                 ScaleTransition st = new ScaleTransition(Duration.millis(140), card);
+                 st.setToX(1.0); st.setToY(1.0); st.play();
+             }
+         });
+ 
+         card.setOnMouseClicked(e -> {
+             mainHBox.getChildren().forEach(n -> {
+                 if (n instanceof VBox v) {
+                     StackPane f = (StackPane) v.getChildren().get(0);
+                     Label l = (Label) v.getChildren().get(2);
+                     f.setStyle(frameStyle(false));
+                     l.setStyle(nameStyle(false));
+                     ScaleTransition st = new ScaleTransition(Duration.millis(130), v);
+                     st.setToX(1.0); st.setToY(1.0); st.play();
+                 }
+             });
+ 
+             frame.setStyle(frameStyle(true));
+             name.setStyle(nameStyle(true));
+             selectedFrame = frame;
+             selectedIndex = idx;
+ 
+             ScaleTransition pop = new ScaleTransition(Duration.millis(160), card);
+             pop.setToX(1.08); pop.setToY(1.08);
+             pop.setAutoReverse(true); pop.setCycleCount(2); pop.play();
+ 
+             updateConfirmButton(true);
+         });
+ 
+         return card;
+     }
+ 
+     /** Enables or disables the confirm button and updates its visual opacity to reflect the state. */
+     private void updateConfirmButton(boolean enabled) {
+         confirmButton.setDisable(!enabled);
+         confirmButton.setStyle(
+                 "-fx-font-family: 'Cinzel'; -fx-font-size: 12; -fx-font-weight: bold;" +
+                         "-fx-letter-spacing: 4; -fx-text-fill: #0c0601;" +
+                         "-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
+                         "-fx-padding: 12 48 12 48; -fx-background-radius: 2;" +
+                         "-fx-opacity: " + (enabled ? "1.0" : "0.3") + ";" +
+                         "-fx-cursor: " + (enabled ? "hand" : "default") + ";"
+         );
+     }
+ 
+     /** Returns the CSS style string for the totem card frame, highlighting it when {@code selected}. */
+     private String frameStyle(boolean selected) {
+         return selected ? "-fx-effect: dropshadow(gaussian, #ffffff, 20, 0.33, 0, 0);" : "";
+     }
+ 
+     /** Returns the CSS style string for the totem name label, brightening it when {@code selected}. */
+     private String nameStyle(boolean selected) {
+         return "-fx-font-family: 'Cinzel'; -fx-font-size: 10; -fx-letter-spacing: 2;" +
+                 "-fx-text-fill: " + (selected ? "#FFD700" : "#ffffff") + ";";
+     }
+ 
+     /** Returns the totem name with only the first letter capitalised. */
+     private String capitalize(Totems t) {
+         String s = t.name().toLowerCase(Locale.ROOT);
+         return Character.toUpperCase(s.charAt(0)) + s.substring(1);
+     }
+ 
+ 
+     /** Submits the selected totem index to the controller when the confirm button is clicked. */
+     @FXML
+     private void onConfirm() {
+         if (selectedIndex >= 0) {
+             controller.totemChoice(selectedIndex);
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index.html b/deliverables/Coverage/htmlReport/ns-13/index.html new file mode 100644 index 0000000..37110f5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..2ccee0e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..e619b1e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..485e336 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..6feb925 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE.html new file mode 100644 index 0000000..0382d86 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..029f14c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..171c5f7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..c6e51ee --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..117182d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View.TUI + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View.TUI

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.View.TUI + + 66.7% + + + (2/3) + + + + 53.3% + + + (24/45) + + + + 26.7% + + + (40/150) + + + + 38.7% + + + (84/217) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + + 88.9% + + + (24/27) + +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-13/sources/source-1.html new file mode 100644 index 0000000..08637a2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/sources/source-1.html @@ -0,0 +1,279 @@ + + + + + + + + Coverage Report > AsciiTable + + + + + + +
+ + +

Coverage Summary for Class: AsciiTable (it.polimi.ingsw.gc14.View.TUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
AsciiTable + + 100% + + + (1/1) + + + + 90.9% + + + (10/11) + + + + 52.6% + + + (40/76) + + + + 82.2% + + + (60/73) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.TUI;
+ import java.util.*;
+ 
+ /**
+  * General-purpose helper for building fixed-width ASCII/Unicode tables in a TUI.
+  *
+  * <p>A table is built by adding rows one at a time, then calling {@link #build()}
+  * to obtain the fully rendered string. Column width is computed automatically
+  * from the widest cell across all rows.
+  *
+  * <p>Cell widths are measured in terminal columns, not Java {@code char} units:
+  * wide characters (emoji, CJK) count as 2 columns each.
+  *
+  * <p>Example usage:
+  * <pre>{@code
+  * AsciiTable table = new AsciiTable(BorderStyle.UNICODE, 3);
+  * table.addHeader("Name", "🍖", "⭐");
+  * table.addRow("Alice", "4", "12");
+  * table.addRow("Bob",   "2", "8");
+  * System.out.println(table.build());
+  * }</pre>
+  */
+ public class AsciiTable {
+     //TODO
+     private final BorderStyle s;
+     //TODO
+     private final int cols;
+     //TODO
+     private final List<List<String>> rows = new ArrayList<>();
+     //TODO
+     private final List<Integer> separators = new ArrayList<>();
+     //TODO
+     public AsciiTable(BorderStyle s, int cols) {
+         this.s = s; this.cols = cols;
+     }
+     //TODO
+     public void addRow(String... cells) { rows.add(Arrays.asList(cells)); }
+     //TODO
+     public void addRow(List<String> cells) { rows.add(cells); }
+     //TODO
+     public void addHeader(String... cells) {
+         rows.add(0, Arrays.asList(cells));
+         separators.add(0);
+     }
+     //TODO
+     public void addSeparator() { separators.add(rows.size() - 1); }
+ 
+     /**
+      * Renders the table to a multi-line string.
+      * Column width is the widest cell in display columns (wide chars = 2), plus 1.
+      */
+     public String build() {
+         var sb = new StringBuilder();
+         int maxWidth = rows.stream()
+                 .mapToInt(x -> x.stream().mapToInt(AsciiTable::displayWidth).max().orElse(0))
+                 .max().orElse(0) + 1;
+         sb.append(hline(s.tl(), s.mt(), s.tr(), maxWidth)).append('\n');
+ 
+         for (int i = 0; i < rows.size(); i++) {
+             sb.append(s.v());
+             for (String cell : rows.get(i))
+                 sb.append(rpad(" " + cell, maxWidth)).append(s.v());
+             sb.append('\n');
+             if (separators.contains(i) && i < rows.size() - 1)
+                 sb.append(hline(s.sl(), s.sx(), s.sr(), maxWidth)).append('\n');
+         }
+         sb.append(hline(s.bl(), s.mb(), s.br(), maxWidth));
+         return sb.toString();
+     }
+     //TODO
+     private String hline(String l, String m, String r, int maxWidth) {
+         var sb = new StringBuilder(l);
+         for (int i = 0; i < cols; i++) {
+             sb.append(s.h().repeat(maxWidth));
+             if (i < cols - 1) sb.append(m);
+         }
+         return sb.append(r).toString();
+     }
+ 
+     /**
+      * Pads {@code s} with trailing spaces so its display width equals {@code w}.
+      * If the string is already at or over {@code w} columns, it is returned as-is.
+      */
+     private static String rpad(String s, int w) {
+         int dw = displayWidth(s);
+         if (dw >= w) return s;
+         return s + " ".repeat(w - dw);
+     }
+ 
+     /**
+      * Places two pre-rendered text blocks side by side, separated by a gap.
+      * Left-block lines are padded to a uniform display width so the right block
+      * always starts at the same column. Uses {@link #displayWidth} for measurement.
+      */
+     public static String sideBySide(List<String> left, List<String> right, int gap) {
+         int leftWidth = left.stream().mapToInt(AsciiTable::displayWidth).max().orElse(0);
+         int maxHeight = Math.max(left.size(), right.size());
+         String padding = " ".repeat(gap);
+ 
+         var sb = new StringBuilder();
+         for (int i = 0; i < maxHeight; i++) {
+             String l = i < left.size() ? left.get(i) : " ".repeat(leftWidth);
+             l = rpad(l, leftWidth);
+             String r = i < right.size() ? right.get(i) : "";
+             sb.append(l).append(padding).append(r).append('\n');
+         }
+         return sb.toString();
+     }
+ 
+     // ── Wide-character width ──────────────────────────────────────────────────
+ 
+     /**
+      * Returns the number of terminal columns required to display {@code s}.
+      * Wide characters (emoji, CJK, full-width) count as 2; all others as 1.
+      */
+     public static int displayWidth(String s) {
+         s = s.replaceAll("\033\\[[^m]*m", "");
+         int w = 0;
+         for (int i = 0; i < s.length(); ) {
+             int cp = s.codePointAt(i);
+             w += isWide(cp) ? 2 : 1;
+             i += Character.charCount(cp);
+         }
+         return w;
+     }
+ 
+     /**
+      * Returns {@code true} when {@code cp} is a wide (2-column) character.
+      * Covers CJK blocks, Hangul, full-width forms, and emoji (including
+      * the specific emoji used in this project: 🍖 U+1F357, ⭐ U+2B50).
+      */
+     private static boolean isWide(int cp) {
+         if (cp < 0x1100) return false;
+         if (cp <= 0x115F) return true;   // Hangul Jamo
+         if (cp < 0x2E80) {
+             // Specific wide symbols below 0x2E80
+             return cp == 0x2B50           // ⭐ STAR
+                 || cp == 0x2B55;          // ⭕ HEAVY LARGE CIRCLE
+         }
+         if (cp <= 0x303E) return true;    // CJK Radicals, Kangxi, CJK Symbols
+         if (cp < 0x3041) return false;
+         if (cp <= 0xA4CF) return true;    // Hiragana, Katakana, Bopomofo, CJK Unified
+         if (cp < 0xA960) return false;
+         if (cp <= 0xA97F) return true;    // Hangul Jamo Extended-A
+         if (cp < 0xAC00) return false;
+         if (cp <= 0xD7AF) return true;    // Hangul Syllables
+         if (cp < 0xF900) return false;
+         if (cp <= 0xFAFF) return true;    // CJK Compatibility Ideographs
+         if (cp < 0xFE10) return false;
+         if (cp <= 0xFE1F) return true;    // Vertical Forms
+         if (cp < 0xFE30) return false;
+         if (cp <= 0xFE6F) return true;    // CJK Compatibility Forms
+         if (cp < 0xFF00) return false;
+         if (cp <= 0xFF60) return true;    // Fullwidth Latin, punctuation
+         if (cp < 0xFFE0) return false;
+         if (cp <= 0xFFE6) return true;    // Fullwidth Signs
+         if (cp < 0x1F004) return false;
+         if (cp <= 0x1FAFF) return true;   // Emoji (mahjong, playing cards, flags,
+                                           // misc symbols, transport, 🍖 U+1F357, ...)
+         if (cp < 0x20000) return false;
+         return cp <= 0x3FFFD;             // CJK Extension B through G
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-13/sources/source-2.html new file mode 100644 index 0000000..9acb87b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/sources/source-2.html @@ -0,0 +1,216 @@ + + + + + + + + Coverage Report > BorderStyle + + + + + + +
+ + +

Coverage Summary for Class: BorderStyle (it.polimi.ingsw.gc14.View.TUI)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
BorderStyle + + 100% + + + (1/1) + + + + 82.4% + + + (14/17) + + + + 88.9% + + + (24/27) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.TUI;
+ 
+ /**
+  * Defines the available border styles used to render {@link AsciiTable}
+  * instances in the text-based user interface.
+  *
+  * <p>Each style stores the characters needed to draw table corners,
+  * horizontal and vertical lines, and junctions.
+  */
+ public enum BorderStyle {
+ 
+     /**
+      * Unicode box-drawing border style.
+      */
+     UNICODE("╔","╗","╚","╝","═","║","╠","╣","╦","╩","╬","├","┤","┼"),
+ 
+     /**
+      * Plain ASCII border style.
+      */
+     ASCII  ("+","+","+","+","-","|","+","+","+","+","+","+","+","+"),
+ 
+     /**
+      * Rounded Unicode border style.
+      */
+     ROUNDED("╭","╮","╰","╯","─","│","├","┤","┬","┴","┼","├","┤","┼");
+ 
+     private final String tl,tr,bl,br,h,v,ml,mr,mt,mb,x,sl,sr,sx;
+ 
+     BorderStyle(String tl,String tr,String bl,String br,
+                 String h, String v, String ml,String mr,
+                 String mt,String mb,String x,
+                 String sl,String sr,String sx) {
+         this.tl = tl; this.tr = tr;
+         this.bl = bl; this.br = br;
+         this.h  = h;  this.v  = v;
+         this.ml = ml; this.mr = mr;
+         this.mt = mt; this.mb = mb;
+         this.x  = x;
+         this.sl = sl; this.sr = sr;
+         this.sx = sx;
+     }
+ 
+     /**
+      * @return the top-left corner character.
+      */
+     public String tl() { return tl; }
+ 
+     /**
+      * @return the top-right corner character.
+      */
+     public String tr() { return tr; }
+ 
+     /**
+      * @return the bottom-left corner character.
+      */
+     public String bl() { return bl; }
+ 
+     /**
+      * @return the bottom-right corner character.
+      */
+     public String br() { return br; }
+ 
+     /**
+      * @return the horizontal line character.
+      */
+     public String h()  { return h;  }
+ 
+     /**
+      * @return the vertical line character.
+      */
+     public String v()  { return v;  }
+ 
+     /**
+      * @return the middle-left junction character.
+      */
+     public String ml() { return ml; }
+ 
+     /**
+      * @return the middle-right junction character.
+      */
+     public String mr() { return mr; }
+ 
+     /**
+      * @return the top-middle junction character.
+      */
+     public String mt() { return mt; }
+ 
+     /**
+      * @return the bottom-middle junction character.
+      */
+     public String mb() { return mb; }
+ 
+     /**
+      * @return the center junction character.
+      */
+     public String x()  { return x;  }
+ 
+     /**
+      * @return the separator-left junction character.
+      */
+     public String sl() { return sl; }
+ 
+     /**
+      * @return the separator-right junction character.
+      */
+     public String sr() { return sr; }
+ 
+     /**
+      * @return the separator center junction character.
+      */
+     public String sx() { return sx; }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-13/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-13/sources/source-3.html new file mode 100644 index 0000000..9e13e82 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-13/sources/source-3.html @@ -0,0 +1,428 @@ + + + + + + + + Coverage Report > TUI + + + + + + +
+ + +

Coverage Summary for Class: TUI (it.polimi.ingsw.gc14.View.TUI)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
TUI + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/74) + + + + 0% + + + (0/117) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View.TUI;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.*;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.View.IView;
+ 
+ import org.jline.reader.LineReader;
+ import org.jline.terminal.Terminal;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+ 
+ /**
+  * Text-based User Interface (TUI) implementation of {@link IView}.
+  *
+  * <p>Single render view: board + menu on top, all players' hands in a
+  * responsive grid below. Hands wrap to a new row when their combined width
+  * would exceed the terminal width.
+  *
+  * <p>All output goes through {@link #display(String)}, which uses
+  * {@link LineReader#printAbove} when a JLine reader is set so that the
+  * readline prompt is correctly redrawn after background-thread renders.
+  */
+ public class TUI implements IView {
+ 
+     private MiniModel model;
+     private String username;
+ 
+     /**
+      * JLine reader — when non-null, all output uses {@code printAbove} so the
+      * readline prompt is preserved after background-thread renders.
+      */
+     private LineReader lineReader;
+ 
+     /** JLine terminal — used to query terminal width for centering and grid layout. */
+     private Terminal terminal;
+ 
+     /**
+      * Constructs a {@code TUI} bound to the given model.
+      *
+      * @param model the model to display; may be {@code null} initially.
+      */
+     public TUI(MiniModel model) {
+         this.model    = model;
+         this.username = "";
+     }
+ 
+     // ── Setters ───────────────────────────────────────────────────────────────
+ 
+     /** Sets the username of the local player. */
+     public void setUsername(String username) {
+         this.username = username;
+     }
+ 
+     /** Updates the model stored in this view. */
+     @Override
+     public void setModel(MiniModel model) {
+         this.model = model;
+     }
+ 
+     /**
+      * Registers the active JLine {@link LineReader}.
+      * Once set, all output routes through {@link LineReader#printAbove} so the
+      * prompt survives background-thread renders.
+      */
+     public void setLineReader(LineReader lineReader) {
+         this.lineReader = lineReader;
+         this.terminal   = lineReader.getTerminal();
+     }
+ 
+     // ── Public render entry points ────────────────────────────────────────────
+ 
+     /**
+      * Default render: dispatches to the right view based on game stage.
+      */
+     @Override
+     public synchronized void render() {
+         if (model == null) return;
+         GameStages stage = model.currentState.getGameStage();
+         if (stage == GameStages.TOTEM_CHOICE) {
+             display(buildTotemsContent());
+         } else if (stage == GameStages.ENDED) {
+             display(buildStandingContent() + "\nType 'rematch' to play again or 'quit' to exit");
+         } else {
+             display(buildBoardContent());
+         }
+     }
+ 
+     /** Renders the board + menu (top) and all players' hands in a grid (bottom). */
+     public void renderBoard() {
+         display(buildBoardContent());
+     }
+ 
+     /** Renders the totem-choice panel. */
+     public void renderTotems() {
+         display(buildTotemsContent());
+     }
+ 
+     /**
+      * Shows an error message combined with the current board in one display call,
+      * so only one {@code printAbove} is issued and the prompt is redrawn correctly.
+      *
+      * @param error   the error type.
+      * @param message the human-readable message to append.
+      */
+     public void showError(ErrorType error, String message) {
+         String text;
+         if (error == ErrorType.WRONG_ACTION
+                 && model != null
+                 && model.currentState.getCurrentPlayer() != null
+                 && !model.currentState.getCurrentPlayer().getUserName().equals(username)) {
+             text = "It's not your turn";
+         } else {
+             text = message;
+             if (error == ErrorType.SERVER_CRASHED) {
+                 text += "\nPress any key to continue";
+             }
+         }
+         printLine(text);
+     }
+ 
+     // ── Content builders (return strings, do not print) ───────────────────────
+ 
+     /**
+      * Builds the main view: board + menu side by side, followed by all players'
+      * hands arranged in a responsive grid.
+      */
+     private String buildBoardContent() {
+         List<String> left  = List.of(boardStamp().split("\n"));
+         List<String> right = List.of(buildAllHandsContent().split("\n"));
+         return AsciiTable.sideBySide(left, right, 3);
+     }
+ 
+     /**
+      * Arranges every player's hand side-by-side, wrapping to a new grid row
+      * whenever the next panel would exceed the terminal width.
+      */
+     private String buildAllHandsContent() {
+         List<Player> players = new ArrayList<>(model.players.values());
+         if (players.isEmpty()) return "";
+ 
+         int n = players.size();
+         int leftCount = Math.min(3, n);
+ 
+         StringBuilder leftSb  = new StringBuilder();
+         StringBuilder rightSb = new StringBuilder();
+         for (int i = 0; i < leftCount; i++)  leftSb.append(players.get(i).toString()).append("\n");
+         for (int i = leftCount; i < n; i++) rightSb.append(players.get(i).toString()).append("\n");
+ 
+         if (rightSb.isEmpty()) return leftSb.toString();
+ 
+         return AsciiTable.sideBySide(
+                 List.of(leftSb.toString().split("\n", -1)),
+                 List.of(rightSb.toString().split("\n", -1)), 3);
+     }
+ 
+     private String buildTotemsContent() {
+         var table = new AsciiTable(BorderStyle.ROUNDED, model.availableTotems.size());
+         List<String> lines = new ArrayList<>();
+         for (int i = 0; i < model.availableTotems.size(); i++) {
+             lines.add(i + "." + model.availableTotems.get(i));
+         }
+         table.addRow(lines);
+         String current = model.currentState.getCurrentPlayer() != null
+                 ? model.currentState.getCurrentPlayer().getUserName() + " — "
+                 : "";
+         return current + "TOTEMS AVAILABLE:\n" + table.build() + "\nType: totem <pos>";
+     }
+ 
+     private String buildStandingContent() {
+         if (model.standingPlayers == null || model.standingPlayers.isEmpty()) return "";
+         StringBuilder sb = new StringBuilder();
+         int size = model.standingPlayers.size();
+         for (int i = 0; i < size / 2; i++) {
+             sb.append(AsciiTable.sideBySide(
+                     List.of(model.standingPlayers.get(i * 2).toString().split("\n")),
+                     List.of(model.standingPlayers.get(i * 2 + 1).toString().split("\n")), 2));
+         }
+         sb.append("\n");
+         if (size % 2 != 0) {
+             sb.append(model.standingPlayers.get(size - 1)).append("\n");
+         }
+         if (model.standingPlayers.get(0).getUserName().equals(username)) {
+             sb.append("GAME ENDED: !!!YOU WON!!!");
+         } else {
+             sb.append("GAME ENDED: !!!YOU LOST!!!");
+         }
+         return sb.toString();
+     }
+ 
+     // ── Core display primitive ────────────────────────────────────────────────
+ 
+     /**
+      * Clears the terminal and displays {@code content}, horizontally centered.
+      *
+      * <p>When a JLine {@link LineReader} is registered, output is routed through
+      * {@link LineReader#printAbove} which pauses readline, prints the content,
+      * and redraws the prompt — safe to call from any thread.
+      * Otherwise, ANSI codes are written directly to stdout.
+      */
+     private void display(String content) {
+         String cleared = "\033[H\033[2J" + center(content);
+         if (lineReader != null) {
+             lineReader.printAbove(cleared);
+         } else {
+             System.out.print(cleared);
+             System.out.println();
+             System.out.flush();
+         }
+     }
+ 
+     /** Prints {@code text} above the prompt without clearing the screen. */
+     private void printLine(String text) {
+         if (lineReader != null) {
+             lineReader.printAbove(text);
+         } else {
+             System.out.println(text);
+             System.out.flush();
+         }
+     }
+ 
+     /**
+      * Horizontally centers each line of {@code content} within the terminal width.
+      * Empty lines are left unpadded. Falls back to the original string when the
+      * terminal width is unknown.
+      */
+     private String center(String content) {
+         if (terminal == null) return content;
+         int termWidth = terminal.getWidth();
+         if (termWidth <= 0) return content;
+ 
+         String[] lines = content.split("\n", -1);
+ 
+         int maxWidth = 0;
+         for (String line : lines) {
+             int w = visibleLength(line);
+             if (w > maxWidth) maxWidth = w;
+         }
+ 
+         int pad = Math.max(0, (termWidth - maxWidth) / 2);
+         if (pad == 0) return content;
+ 
+         String prefix = " ".repeat(pad);
+         StringBuilder sb = new StringBuilder();
+         for (int i = 0; i < lines.length; i++) {
+             if (!lines[i].isEmpty()) sb.append(prefix);
+             sb.append(lines[i]);
+             if (i < lines.length - 1) sb.append("\n");
+         }
+         return sb.toString();
+     }
+ 
+     /** Returns the display width of a string in terminal columns, stripping ANSI escape codes. */
+     private int visibleLength(String line) {
+         return AsciiTable.displayWidth(line);
+     }
+ 
+     // ── Board / players stamp helpers ─────────────────────────────────────────
+ 
+     /**
+      * Returns the board state as a multi-line string: turn order, upper cards,
+      * offer track, lower cards.
+      *
+      * @return multi-line board string.
+      */
+     public String boardStamp() {
+         var offerTrack = new AsciiTable(BorderStyle.ROUNDED, model.slotPlayerMap.size());
+         List<String> slotNames   = new ArrayList<>();
+         List<String> slotPlayers = new ArrayList<>();
+ 
+         int index = 0;
+         for (Map.Entry<Slot, Player> entry : model.slotPlayerMap.entrySet()) {
+             slotNames.add((index++) + "." + entry.getKey().toStringTUI());
+             slotPlayers.add(entry.getValue() != null ? entry.getValue().getUserName() : " ");
+         }
+ 
+         var upperCards = new AsciiTable(BorderStyle.ROUNDED, 2);
+         var lowerCards = new AsciiTable(BorderStyle.ROUNDED, 2);
+         upperCards.addHeader("Char/Events", "Building");
+         lowerCards.addHeader("Char/Events", "Building");
+ 
+         int maxU = Math.max(model.upperListTribeCards.size(), model.upperListBuildingCards.size());
+         for (int i = 0; i < maxU; i++) {
+             String t = i < model.upperListTribeCards.size() ? i + model.upperListTribeCards.get(i).toStringBoard() : "";
+             String b = i < model.upperListBuildingCards.size() ? i + model.upperListBuildingCards.get(i).toString() : "";
+             upperCards.addRow(t, b);
+         }
+ 
+         int maxL = Math.max(model.lowerListTribeCards.size(), model.lowerListBuildingCards.size());
+         for (int i = 0; i < maxL; i++) {
+             String t = i < model.lowerListTribeCards.size() ? i + model.lowerListTribeCards.get(i).toStringBoard() : "";
+             String b = i < model.lowerListBuildingCards.size() ? i + model.lowerListBuildingCards.get(i).toString() : "";
+             lowerCards.addRow(t, b);
+         }
+ 
+         offerTrack.addRow(slotPlayers);
+         offerTrack.addRow(slotNames);
+ 
+         String upperSection = upperCards.build();
+ 
+         String middleSection = model.orderLogicCard.toString() + offerTrack.build();
+ 
+         String lowerSection = lowerCards.build();
+ 
+         return model.currentState + "\n"
+                 + upperSection + "\n"
+                 + middleSection + "\n"
+                 + lowerSection;
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index.html b/deliverables/Coverage/htmlReport/ns-14/index.html new file mode 100644 index 0000000..10d849d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..03de07a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..ddffd04 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..2abb24f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..0386fb0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE.html new file mode 100644 index 0000000..638f364 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..569d0eb --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..bfef67e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..e4fc43b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..826f103 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.View + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.View

+ + + + + + + +
Package
it.polimi.ingsw.gc14.View
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-14/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-14/sources/source-1.html new file mode 100644 index 0000000..7186b34 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-14/sources/source-1.html @@ -0,0 +1,94 @@ + + + + + + + + Coverage Report > IView + + + + + + +
+ + +

Coverage Summary for Class: IView (it.polimi.ingsw.gc14.View)

+ + + + + + + + + +
Class
IView
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.View;
+ 
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ 
+ /** View interface implemented by both the TUI and GUI. */
+ public interface IView {
+     /**
+      * Updates the view's local copy of the game model.
+      *
+      * @param miniModel the latest mini model received from the server.
+      */
+     void setModel(MiniModel miniModel);
+ 
+     /** Re-renders the view based on the current mini model state. */
+     void render();
+ 
+     /**
+      * Displays an error message to the user.
+      *
+      * @param error the error type.
+      * @param message a human-readable description of the error.
+      */
+     void showError(ErrorType error, String message);
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index.html b/deliverables/Coverage/htmlReport/ns-15/index.html new file mode 100644 index 0000000..3300bc4 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..c126135 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..188f371 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..4d6fc6d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..b189787 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE.html new file mode 100644 index 0000000..6bf87c2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..93882ef --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..3c9ccbf --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..97271af --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..bd673be --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,68 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Common + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Common

+ + + + + + + +
Package
it.polimi.ingsw.gc14.Network.RMI.Common
+ +
+
+ + + + + +
+Class
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-15/sources/source-1.html new file mode 100644 index 0000000..726abff --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/sources/source-1.html @@ -0,0 +1,102 @@ + + + + + + + + Coverage Report > IClientCallback + + + + + + +
+ + +

Coverage Summary for Class: IClientCallback (it.polimi.ingsw.gc14.Network.RMI.Common)

+ + + + + + + + + +
Class
IClientCallback
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Common;
+ 
+ import it.polimi.ingsw.gc14.Model.*;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.io.Serializable;
+ import java.rmi.*;
+ import java.util.Map;
+ 
+ /**
+  * Callback interface used by the server to notify an RMI client about
+  * game updates and incoming network actions.
+  *
+  * <p>Implementations of this interface are remotely accessible and
+  * serializable.
+  */
+ public interface IClientCallback extends Remote, Serializable {
+ 
+     /**
+      * Notifies the client that the game model has been initialized or updated.
+      *
+      * @param miniModel the current mini model of the game.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void onGameInit(MiniModel miniModel) throws RemoteException;
+ 
+     /**
+      * Notifies the client about a network action to process.
+      *
+      * @param action the network event received from the server.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void onAction(NetworkEvent action) throws RemoteException;
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-15/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-15/sources/source-2.html new file mode 100644 index 0000000..7087aeb --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-15/sources/source-2.html @@ -0,0 +1,174 @@ + + + + + + + + Coverage Report > IGameServer + + + + + + +
+ + +

Coverage Summary for Class: IGameServer (it.polimi.ingsw.gc14.Network.RMI.Common)

+ + + + + + + + + +
Class
IGameServer
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Common;
+ 
+ import it.polimi.ingsw.gc14.ErrorType;
+ 
+ import java.rmi.*;
+ 
+ /**
+  * Remote interface used by RMI clients to interact with the game server.
+  */
+ public interface IGameServer extends Remote {
+ 
+     /**
+      * Adds a player to the game and registers the callback used by the server
+      * to notify the corresponding RMI client.
+      *
+      * @param username     the username chosen by the player.
+      * @param preferredInt the desired number of players proposed by this client.
+      * @param callback     the remote callback associated with the client.
+      * @return {@code null} if the player joins successfully;
+      *         an {@link it.polimi.ingsw.gc14.ErrorType} value describing the rejection otherwise.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     ErrorType joinGame(String username, int preferredInt, IClientCallback callback) throws RemoteException;
+ 
+     /**
+      * Requests to draw a tribe card from the upper tribe card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos            the position of the selected card.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void drawUpperTribeCard(String playerUsername, int pos) throws RemoteException;
+ 
+     /**
+      * Requests to draw a tribe card from the lower tribe card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos            the position of the selected card.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void drawLowerTribeCard(String playerUsername, int pos) throws RemoteException;
+ 
+     /**
+      * Requests to draw a building card from the upper building card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos            the position of the selected card.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void drawUpperBuildingCard(String playerUsername, int pos) throws RemoteException;
+ 
+     /**
+      * Requests to draw a building card from the lower building card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos            the position of the selected card.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void drawLowerBuildingCard(String playerUsername, int pos) throws RemoteException;
+ 
+     /**
+      * Requests to skip the current player's optional action.
+      *
+      * @param playerUsername the username of the player skipping the action.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void skipTurn(String playerUsername) throws RemoteException;
+ 
+     /**
+      * Requests to assign the specified player to a slot.
+      *
+      * @param playerUsername the username of the player making the slot choice.
+      * @param pos            the position of the selected slot.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void slotChoice(String playerUsername, int pos) throws RemoteException;
+ 
+     /**
+      * Requests to assign the selected totem to the specified player.
+      *
+      * @param playerUsername the username of the player making the totem choice.
+      * @param totems         the name of the selected totem.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void totemChoice(String playerUsername, String totems) throws RemoteException;
+ 
+     /**
+      * Heartbeat method called periodically by the client to signal
+      * that it is still connected.
+      *
+      * <p>This method mirrors the PING/PONG mechanism used in the TCP
+      * heartbeat channel.
+      *
+      * @param username the username of the client sending the heartbeat ping.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void ping(String username) throws RemoteException;
+ 
+     /**
+      * Notifies the server of a voluntary disconnection for the specified player.
+      *
+      * @param username the username of the player disconnecting.
+      * @throws RemoteException if an RMI communication error occurs.
+      */
+     void disconnectPlayer(String username) throws RemoteException;
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index.html b/deliverables/Coverage/htmlReport/ns-2/index.html new file mode 100644 index 0000000..db0b2e1 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..2594ac5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..004edfe --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..f57bad3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..05ae182 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE.html new file mode 100644 index 0000000..fceb909 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..9862c39 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..abc861a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..9fa2653 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..afa2006 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Controller + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Controller

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Controller + + 50% + + + (1/2) + + + + 45.2% + + + (14/31) + + + + 69.2% + + + (18/26) + + + + 65.6% + + + (42/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-2/sources/source-1.html new file mode 100644 index 0000000..edf7980 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/sources/source-1.html @@ -0,0 +1,314 @@ + + + + + + + + Coverage Report > ClientController + + + + + + +
+ + +

Coverage Summary for Class: ClientController (it.polimi.ingsw.gc14.Controller)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientController + + 0% + + + (0/1) + + + + 0% + + + (0/16) + + + + 0% + + + (0/8) + + + + 0% + + + (0/21) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Controller;
+ 
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.IClient;
+ import it.polimi.ingsw.gc14.View.IView;
+ 
+ 
+ /**
+  * Controller responsible for coordinating the client-side components,
+  * including the view, the network client and the local mini model.
+  *
+  * <p>It receives user actions from the view, performs basic client-side
+  * checks and forwards valid requests to the network client.
+  */
+ public class ClientController {
+ 
+     /** Local mini model representing the client-side game state. */
+     private MiniModel miniModel;
+ 
+     /** View of the client. */
+     private IView view;
+ 
+     /** Network client, either TCP or RMI. */
+     private IClient client;
+ 
+     /** Username associated with this client. */
+     private String myUsername;
+ 
+     /**
+      * Constructs a client controller with the specified view.
+      *
+      * <p>The network client is initially unset and an empty local mini model
+      * is created.
+      *
+      * @param view the client view, either TUI or GUI.
+      */
+     public ClientController(IView view) {
+         this.view = view;
+         this.client = null;
+     }
+ 
+     /**
+      * Returns the local mini model.
+      *
+      * @return the local mini model.
+      */
+     public MiniModel getMiniModel() {
+         return miniModel;
+     }
+ 
+     /**
+      * Returns the client view.
+      *
+      * @return the client view.
+      */
+     public IView getView() {
+         return view;
+     }
+ 
+     /**
+      * Returns the username associated with this client.
+      *
+      * @return the username.
+      */
+     public String getMyUsername() {
+         return myUsername;
+     }
+ 
+     /**
+      * Sets the network client.
+      *
+      * @param client the client to set, either TCP or RMI.
+      */
+     public void setClient(IClient client) {
+         this.client = client;
+     }
+ 
+     /**
+      * Gets the network client.
+      *
+      * @return client return the client, either TCP or RMI.
+      */
+     public IClient getClient() {
+         return this.client;
+     }
+ 
+     /**
+      * Sets the local mini model and updates the view accordingly.
+      *
+      * @param model the mini model to set.
+      */
+     public void setModel(MiniModel model) {
+         this.miniModel = model;
+         view.setModel(miniModel);
+     }
+ 
+     /**
+      * Sets the username associated with this client.
+      *
+      * @param username the username to set.
+      */
+     public void setMyUsername(String username) {
+         this.myUsername = username;
+     }
+ 
+ 
+     /**
+      * Requests to draw a tribe card from the upper list.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      *
+      * @param pos the index of the card to draw.
+      */
+     public void drawUpperTribeCard(int pos) {
+         client.drawUpperTribeCard(myUsername, pos);
+ 
+     }
+ 
+     /**
+      * Requests to draw a tribe card from the lower list.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      *
+      * @param pos the index of the card to draw.
+      */
+     public void drawLowerTribeCard(int pos) {
+         client.drawLowerTribeCard(myUsername, pos);
+ 
+     }
+ 
+     /**
+      * Requests to draw a building card from the upper list.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      *
+      * @param pos the index of the card to draw.
+      */
+     public void drawUpperBuildingCard(int pos) {
+         client.drawUpperBuildingCard(myUsername, pos);
+ 
+     }
+ 
+     /**
+      * Requests to draw a building card from the lower list.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      *
+      * @param pos the index of the card to draw.
+      */
+     public void drawLowerBuildingCard(int pos) {
+         client.drawLowerBuildingCard(myUsername, pos);
+     }
+ 
+     /**
+      * Requests to skip the current turn.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      */
+     public void skipTurn() {
+         client.skipTurn(myUsername);
+     }
+ 
+     /**
+      * Requests the selection of a slot by the specified player.
+      *
+      * <p>The request is forwarded to the network client; the server validates it.
+      *
+      * @param pos the index of the selected slot.
+      */
+     public void slotChoice(int pos) {
+         client.slotChoice(myUsername, pos);
+     }
+ 
+     /**
+      * Handles the selection of a totem by the specified player.
+      *
+      * <p>If the specified player is not the current player, an error message
+      * is shown. Otherwise, the selected totem is retrieved from the available
+      * totems list and the choice is forwarded to the network client.
+      *
+      * @param pos the index of the selected totem in the available totems list.
+      */
+     public void totemChoice(int pos) {
+         if (miniModel == null || miniModel.availableTotems == null
+                 || pos < 0 || pos >= miniModel.availableTotems.size())
+             return;
+         client.totemChoice(myUsername, String.valueOf(miniModel.availableTotems.get(pos)));
+     }
+ 
+     /**
+      * Notifies the server of a voluntary disconnection and closes the
+      * network client connection.
+      */
+     public void disconnect()
+     {
+         client.notifyDisconnection();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-2/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-2/sources/source-2.html new file mode 100644 index 0000000..09f3c48 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-2/sources/source-2.html @@ -0,0 +1,332 @@ + + + + + + + + Coverage Report > GameController + + + + + + +
+ + +

Coverage Summary for Class: GameController (it.polimi.ingsw.gc14.Controller)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameController + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (18/18) + + + + 97.7% + + + (42/43) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Controller;
+ 
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Totems;
+ 
+ /**
+  * Controller responsible for managing interactions with the {@link Game} model.
+  *
+  * <p>It provides methods to update the game state by delegating player-related
+  * actions and game actions to the underlying model.
+  */
+ public class GameController {
+ 
+     /**
+      * The game model managed by this controller.
+      */
+     private Game model;
+ 
+     /**
+      * Creates a GameController associated with the specified game model.
+      *
+      * @param model the game model managed by this controller.
+      */
+     public GameController(Game model) {
+         this.model = model;
+     }
+ 
+     /**
+      * Creates a GameController without an associated game model.
+      */
+     public GameController() {
+     }
+ 
+     /**
+      * Marks the player associated with the specified username as disconnected.
+      *
+      * @param username the username of the player who disconnected.
+      * @return {@code true} if the disconnection is handled successfully,
+      *         {@code false} if no player with the specified username exists
+      *         or if the operation fails.
+      */
+     public synchronized boolean disconnectedPlayer(String username)
+     {
+         Player player= model.getPlayerByUsername(username);
+         if(player==null)
+             return false;
+         return model.disconnectedPlayer(player);
+     }
+ 
+     /**
+      * Marks the player associated with the specified username as reconnected.
+      *
+      * @param username the username of the player who reconnected.
+      * @return {@code true} if the reconnection is handled successfully,
+      *         {@code false} if no player with the specified username exists
+      *         or if the operation fails.
+      */
+     public synchronized boolean reconnectPlayer(String username)
+     {
+         Player player= model.getPlayerByUsername(username);
+         if(player==null)
+             return false;
+         return model.reconnectPlayer(player);
+     }
+ 
+     /**
+      * Returns the game model managed by this controller.
+      *
+      * @return the game model managed by this controller.
+      */
+     public synchronized Game getModel() {
+         return model;
+     }
+ 
+     /**
+      * Updates the game model managed by this controller.
+      *
+      * @param model the new game model managed by this controller.
+      */
+     public synchronized void setModel(Game model) {
+         this.model = model;
+     }
+ 
+     /**
+      * Attempts to add a new player with the specified username to the game model.
+      *
+      * @param username the username of the player to add.
+      * @return {@code true} if the player is successfully added,
+      *         {@code false} otherwise.
+      */
+     public synchronized boolean addPlayer(String username) {
+         return model.addPlayer(new Player(username));
+     }
+ 
+     /**
+      * Attempts to draw an upper tribe card for the specified player
+      * from the specified position.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the upper tribe card to draw.
+      * @return {@code true} if the action succeeds,
+      *         {@code false} if the player does not exist or if the draw operation fails.
+      */
+     public synchronized boolean drawUpperTribeCard(String playerUsername,int pos) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.drawUpperTribeCardByIndex(player, pos);
+     }
+ 
+     /**
+      * Attempts to draw a lower tribe card for the specified player
+      * from the specified position.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the lower tribe card to draw.
+      * @return {@code true} if the action succeeds,
+      *         {@code false} if the player does not exist or if the draw operation fails.
+      */
+     public synchronized boolean drawLowerTribeCard(String playerUsername,int pos) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.drawLowerTribeCardByIndex(player, pos);
+     }
+ 
+     /**
+      * Attempts to draw an upper building card for the specified player
+      * from the specified position.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the upper building card to draw.
+      * @return {@code true} if the action succeeds,
+      *         {@code false} if the player does not exist or if the draw operation fails.
+      */
+     public synchronized boolean drawUpperBuildingCard(String playerUsername,int pos) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.drawUpperBuildingCardByIndex(player, pos);
+     }
+ 
+     /**
+      * Attempts to draw a lower building card for the specified player
+      * from the specified position.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the lower building card to draw.
+      * @return {@code true} if the action succeeds,
+      *         {@code false} if the player does not exist or if the draw operation fails.
+      */
+     public synchronized boolean drawLowerBuildingCard(String playerUsername,int pos) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.drawLowerBuildingCardByIndex(player, pos);
+     }
+ 
+ 
+     /**
+      * Skips the card drawing action for the specified player.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @return {@code true} if the skip action is valid and successfully performed,
+      *         {@code false} if the player does not exist or if the action is not valid.
+      */
+     public synchronized boolean skipTurn(String playerUsername) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.skipTurn(player);
+     }
+ 
+ 
+ 
+     /**
+      * Attempts to perform the slot choice action for the specified player
+      * at the specified position.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the chosen slot.
+      * @return {@code true} if the action succeeds,
+      *         {@code false} if the player does not exist or if the slot choice operation fails.
+      */
+     public synchronized boolean slotChoice(String playerUsername,int pos) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.slotChoiceByIndex(player, pos);
+     }
+ 
+     /**
+      * Applies the totem choice made by the player associated with the specified username.
+      *
+      * @param playerUsername the username of the player making the choice.
+      * @param totem the name of the selected totem.
+      * @return {@code true} if the choice is handled successfully,
+      *         {@code false} if no player with the specified username exists
+      *         or if the choice operation fails.
+      */
+     public synchronized boolean totemChoice(String playerUsername,String totem) {
+         Player player= model.getPlayerByUsername(playerUsername);
+         if(player==null)
+             return false;
+         return model.totemChoice(player, Totems.valueOf(totem));
+     }
+ 
+     /**
+      * Ends the game due to forfeit: all remaining players are absent,
+      * so the game is terminated and final scores are computed.
+      */
+     public synchronized void endGameForfeit() {
+         model.endGameForfeit();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index.html b/deliverables/Coverage/htmlReport/ns-3/index.html new file mode 100644 index 0000000..dcbaffb --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..4bf88a0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..0ca7428 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..1c8df40 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..10cdff3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE.html new file mode 100644 index 0000000..2c58426 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..4a0a5b6 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..73573d5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..6347077 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..4d59068 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,405 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model + + 90.9% + + + (10/11) + + + + 77.6% + + + (97/125) + + + + 73.5% + + + (349/475) + + + + 82% + + + (547/667) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + + 100% + + + (6/6) + +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
Player + + 100% + + + (2/2) + + + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
DecksCreator + + 100% + + + (3/3) + + + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-1.html new file mode 100644 index 0000000..d3dc7e5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-1.html @@ -0,0 +1,405 @@ + + + + + + + + Coverage Report > DecksCreator + + + + + + +
+ + +

Coverage Summary for Class: DecksCreator (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class + Method, % + + Branch, % + + Line, % +
DecksCreator + + 100% + + + (7/7) + + + + 100% + + + (57/57) + + + + 88.6% + + + (70/79) + +
DecksCreator$1 + + 100% + + + (1/1) + + + + 100% + + + (1/1) + +
DecksCreator$2 + + 100% + + + (1/1) + + + + 100% + + + (1/1) + +
DecksCreator$BuildingCardDefinition
DecksCreator$TribeCardDefinition
Total + + 100% + + + (9/9) + + + + 100% + + + (57/57) + + + + 88.9% + + + (72/81) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ import com.google.gson.*;
+ import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.*;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.CavePaintings;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Sustenance;
+ 
+ import java.io.*;
+ import java.lang.reflect.Type;
+ import java.util.*;
+ 
+ /**
+  * Utility class responsible for loading and creating decks of cards and slots for the game.
+  * Cards are loaded from JSON resource files and instantiated according to their type and parameters.
+  */
+ public class DecksCreator {
+ 
+     private DecksCreator() {}
+ 
+     /**
+      * Loads the tribe card deck for the specified era from the corresponding JSON resource file.
+      *
+      * @param era the era number (1, 2, or 3).
+      * @return a list of {@link TribeCard} objects for the specified era.
+      * @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
+      */
+     public static List<TribeCard> loadTribeDeckByEra(int era) throws IllegalArgumentException
+     {
+         return switch (era) {
+             case 1 -> loadTribeDeck("/Cards/tribe_era1.json");
+             case 2 -> loadTribeDeck("/Cards/tribe_era2.json");
+             case 3 -> loadTribeDeck("/Cards/tribe_era3.json");
+             default -> throw new IllegalArgumentException();
+         };
+     }
+ 
+     /**
+      * Loads a tribe card deck from the specified JSON resource file path.
+      *
+      * @param resourcePath the path to the JSON resource file.
+      * @return a list of {@link TribeCard} objects defined in the resource file.
+      * @throws RuntimeException if the resource file is not found or an error occurs while reading it.
+      */
+     public static List<TribeCard> loadTribeDeck(String resourcePath) {
+         Gson gson = new Gson();
+         Type listType = new com.google.gson.reflect.TypeToken<List<TribeCardDefinition>>(){}.getType();
+ 
+         InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);
+         if (is == null) {
+             throw new RuntimeException("Resource file not found: " + resourcePath);
+         }
+ 
+         try (Reader reader = new InputStreamReader(is)) {
+             List<TribeCardDefinition> definitions = gson.fromJson(reader, listType);
+             List<TribeCard> cards = new ArrayList<>();
+             for (TribeCardDefinition def : definitions) {
+                 cards.add(createCard(def));
+             }
+             return cards;
+         } catch (IOException e) {
+             throw new RuntimeException("Error loading deck: " + resourcePath, e);
+         }
+     }
+ 
+     /**
+      * Loads the building card deck for the specified era, filtering cards from the global building deck.
+      *
+      * @param era the era number (1, 2, or 3).
+      * @return a list of {@link BuildingCard} objects belonging to the specified era.
+      * @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
+      */
+     public static List<BuildingCard> loadBuildingDeckByEra(int era) throws IllegalArgumentException
+     {
+         if(era<=0 || era>3) throw new IllegalArgumentException();
+         return loadBuildingDeck("/Cards/buildingCards.json").stream().filter(x->x.getEra()==era).toList();
+     }
+ 
+     /**
+      * Loads the full building card deck from the specified JSON resource file path.
+      *
+      * @param resourcePath the path to the JSON resource file.
+      * @return a list of {@link BuildingCard} objects defined in the resource file.
+      * @throws RuntimeException if the resource file is not found or an error occurs while reading it.
+      */
+     public static List<BuildingCard> loadBuildingDeck(String resourcePath) {
+         Gson gson = new Gson();
+         Type listType = new com.google.gson.reflect.TypeToken<List<BuildingCardDefinition>>(){}.getType();
+ 
+         InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);
+         if (is == null) {
+             throw new RuntimeException("Resource file not found: " + resourcePath);
+         }
+ 
+         try (Reader reader = new InputStreamReader(is)) {
+             List<BuildingCardDefinition> definitions = gson.fromJson(reader, listType);
+             List<BuildingCard> cards = new ArrayList<>();
+             for (BuildingCardDefinition def : definitions) {
+                 cards.add(createCard(def));
+             }
+             return cards;
+         } catch (IOException e) {
+             throw new RuntimeException("Error loading deck: " + resourcePath, e);
+         }
+     }
+ 
+     /**
+      * Creates and returns the list of slots used as the game board.
+      * Slots are labeled with the letters A through G.
+      *
+      * @return a list of {@link Slot} objects representing the game board.
+      */
+     public static List<Slot> loadSlotDeck()
+     {
+         List<Slot> slots = new ArrayList<>();
+         char[]chars={'A','B','C','D','E','F','G'};
+         for(char c : chars)
+             slots.add(new Slot(c));
+         return slots;
+     }
+ 
+     /**
+      * Instantiates a {@link TribeCard} from the given definition.
+      * Depending on whether the card is an event or a character, the appropriate subclass is created
+      * using the type and parameters specified in the definition.
+      *
+      * @param def the {@link TribeCardDefinition} containing the card's type, era, and parameters.
+      * @return the instantiated {@link TribeCard}.
+      * @throws IllegalArgumentException if the card type is unknown or the parameters are invalid.
+      */
+     private static TribeCard createCard(TribeCardDefinition def) {
+         int era = def.era;
+         int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray();
+         if(def.isEvent)
+         {
+             return switch (def.type) {
+                 case "Sustenance" -> new Sustenance(def.id,era,p[0]);
+                 case "Hunt" -> new Hunt(def.id,era,p[0]);
+                 case "CavePaintings" -> new CavePaintings(def.id,era,p[0],p[1],p[2]);
+                 case "ShamanicRitual" -> new ShamanicRitual(def.id,era,p[0],p[1]);
+                 default -> throw new IllegalArgumentException("Unknown event type: " + def.type);
+             };
+         }
+         return switch (def.type) {
+             case "Hunter" -> p.length == 0
+                     ? new Hunter(def.id,era, def.armed)
+                     : new Hunter(def.id,era, def.armed, p[0]);
+             case "Builder" -> switch (p.length) {
+                 case 2 -> new Builder(def.id,era, p[0], p[1]);
+                 case 3 -> new Builder(def.id,era, p[0], p[1], p[2]);
+                 default -> throw new IllegalArgumentException("Builder: invalid parameters");
+             };
+             case "Gatherer" -> switch (p.length) {
+                 case 0 -> new Gatherer(def.id,era);
+                 case 1 -> new Gatherer(def.id,era, p[0]);
+                 default -> throw new IllegalArgumentException("Gatherer: invalid parameters");
+             };
+             case "Artist" -> switch (p.length) {
+                 case 0 -> new Artist(def.id,era);
+                 case 1 -> new Artist(def.id,era, p[0]);
+                 default -> throw new IllegalArgumentException("Artist: invalid parameters");
+             };
+             case "Inventor" -> switch (p.length) {
+                 case 1 -> new Inventor(def.id,era, p[0]);
+                 case 2 -> new Inventor(def.id,era, p[0], p[1]);
+                 default -> throw new IllegalArgumentException("Inventor: invalid parameters");
+             };
+             case "Shaman" -> switch (p.length) {
+                 case 1 -> new Shaman(def.id,era, p[0]);
+                 case 2 -> new Shaman(def.id,era, p[0], p[1]);
+                 default -> throw new IllegalArgumentException("Shaman: invalid parameters");
+             };
+             default -> throw new IllegalArgumentException("Unknown card type: " + def.type);
+         };
+     }
+ 
+     /**
+      * Instantiates a {@link BuildingCard} from the given definition.
+      * The appropriate subclass is selected based on the effect ID specified in the definition.
+      * If no specific subclass matches the effect ID, a base {@link BuildingCard} is created.
+      *
+      * @param def the {@link BuildingCardDefinition} containing the card's effect ID, era, price, prestige value, and parameters.
+      * @return the instantiated {@link BuildingCard}.
+      */
+     private static BuildingCard createCard(BuildingCardDefinition def) {
+         return switch (def.effectId) {
+             case 0 -> new Building0(def.id,def.era, def.price, def.prestigeValue);
+             case 1 -> new Building1(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()));
+             case 4 -> new Building4(def.id,def.era, def.price, def.prestigeValue);
+             case 8 -> new Building8(def.id,def.era, def.price, def.prestigeValue);
+             case 10 -> new Building10(def.id,def.era, def.price, def.prestigeValue);
+             case 11 -> new Building11(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()), ((Double) def.params.get(1)).intValue());
+             case 13 -> new Building13(def.id,def.era, def.price, def.prestigeValue);
+             default -> new BuildingCard(def.id,def.effectId, def.era, def.price, def.prestigeValue);
+         };
+ 
+     }
+ 
+     /**
+      * Internal data class representing the raw definition of a tribe card as loaded from a JSON file.
+      * Contains the card identifier, type, era, whether it is armed, whether it is an event card,
+      * and a list of additional parameters.
+      */
+     private static class TribeCardDefinition {
+         String id;
+         String type;
+         int era;
+         boolean armed;
+         boolean isEvent;
+         List<Object> params; // Object to support mixed boolean and numeric parameters from JSON
+     }
+ 
+     /**
+      * Internal data class representing the raw definition of a building card as loaded from a JSON file.
+      * Contains the card identifier, effect ID, era, price, prestige value, and a list of additional parameters.
+      */
+     private static class BuildingCardDefinition {
+         String id;
+         int effectId;
+         int era;
+         int price;
+         int prestigeValue;
+         List<Object> params; // Object to support mixed boolean and numeric parameters from JSON
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-2.html new file mode 100644 index 0000000..e3a703b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-2.html @@ -0,0 +1,1135 @@ + + + + + + + + Coverage Report > Game + + + + + + +
+ + +

Coverage Summary for Class: Game (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Game + + 100% + + + (1/1) + + + + 90.9% + + + (40/44) + + + + 68.1% + + + (209/307) + + + + 83.8% + + + (285/340) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
+ import it.polimi.ingsw.gc14.Model.GamePackage.Board;
+ import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
+ import it.polimi.ingsw.gc14.Model.Orders.Order2;
+ import it.polimi.ingsw.gc14.Model.Orders.Order3;
+ import it.polimi.ingsw.gc14.Model.Orders.Order4;
+ import it.polimi.ingsw.gc14.Model.Orders.Order5;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ 
+ import java.io.Serializable;
+ import java.util.*;
+ import java.util.stream.Collectors;
+ import java.util.stream.Stream;
+ 
+ /**
+  * Represents the main game model.
+  * A Game object stores the players, the current state of the match,
+  * the slot assignments, the board, and the logic required to manage the game flow.
+  */
+ public class Game implements Serializable {
+ 
+     /**
+      * The final ranking of players at the end of the game.
+      */
+     private ArrayList<Player> playerStanding;
+ 
+     /**
+      * Returns the final ranking of players.
+      *
+      * @return the list of players ordered according to their final standing.
+      */
+     public ArrayList<Player> getPlayerStanding() {
+         return playerStanding;
+     }
+ 
+     /**
+      * Returns the list of players participating in the game.
+      *
+      * @return a copy of the list of players currently participating in the game.
+      */
+     public List<Player> getPlayers() {
+         return playersList;
+     }
+ 
+     /**
+      * Returns the list of totems that have not yet been assigned to any player.
+      *
+      * @return the list of currently available totems.
+      */
+     public List<Totems>getAvailableTotems() {
+         List<Totems> totems=new ArrayList<>(List.of(Totems.values()));
+         playersList.forEach(player -> {if(player.getTotem()!=null)totems.remove(player.getTotem());});
+         return totems;
+     }
+ 
+     /**
+      * Queue containing the players who still have to choose their totem.
+      */
+     private Queue<Player> totemChoiceQueue = new LinkedList<>();
+ 
+     /**
+      * Assigns the selected totem to the specified player during the totem choice phase.
+      *
+      * <p>The choice is accepted only if the game is currently in the
+      * {@link GameStages#TOTEM_CHOICE} stage, the player is the current one,
+      * and the selected totem is still available.
+      *
+      * <p>After a valid choice, the method advances to the next player in the queue.
+      * If all players have completed the selection, the game moves to the slot choice phase.
+      * Disconnected players are automatically assigned a random available totem.
+      *
+      * @param player the player making the totem choice.
+      * @param totem  the selected totem.
+      * @return {@code true} if the choice is applied successfully, {@code false} otherwise.
+      */
+     public synchronized boolean totemChoice(Player player,Totems totem) {
+         if(currentState.getGameStage() != GameStages.TOTEM_CHOICE)
+             return false;
+         if(!getCurrentState().getCurrentPlayer().equals(player))
+             return false;
+         if(!getAvailableTotems().contains(totem))
+         {
+             return false;
+         }
+         player.setTotem(totem);
+         Player nextPlayer= totemChoiceQueue.poll();
+ 
+         if(nextPlayer==null)
+         {
+             currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
+             currentState.playerUpdate(orderLogicCard.pull(),null);
+         }
+         else
+         {
+             while(disconnectedPlayers.containsKey(nextPlayer)&& disconnectedPlayers.get(nextPlayer))
+             {
+                 nextPlayer.setTotem(getAvailableTotems().get(new Random().nextInt(0,getAvailableTotems().size())));
+                 nextPlayer=totemChoiceQueue.poll();
+                 if(nextPlayer==null)
+                 {
+                     currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
+                     currentState.playerUpdate(orderLogicCard.pull(),null);
+                     return true;
+                 }
+             }
+             currentState.playerUpdate(nextPlayer,null);
+         }
+         return true;
+     }
+ 
+     /**
+      * Map tracking the players who are currently disconnected.
+      * Key: player; value: {@code true} if currently disconnected, {@code false} if reconnected.
+      */
+     private Map<Player,Boolean> disconnectedPlayers = new HashMap<>();
+ 
+     /**
+      * Returns an unmodifiable view of the disconnected-players map.
+      *
+      * @return map from player to disconnection status.
+      */
+     public Map<Player,Boolean> getDisconnectedPlayers() {
+         return Collections.unmodifiableMap(disconnectedPlayers);
+     }
+ 
+     /**
+      * Marks the specified player as disconnected and updates the game flow accordingly.
+      *
+      * <p>If the player disconnects during the waiting phase, they are removed from
+      * the player list and from the totem choice queue. If the disconnected player is
+      * the current one, the game advances to the next suitable player or, during the
+      * totem choice phase, handles the remaining selection flow automatically.
+      *
+      * @param player the player who disconnected.
+      * @return {@code true} if the disconnection is handled successfully,
+      *         {@code false} if the player was already marked as disconnected.
+      */
+     public synchronized boolean disconnectedPlayer(Player player)
+     {
+         if(disconnectedPlayers.containsKey(player) && disconnectedPlayers.get(player))
+         {
+             return false;
+         }
+         disconnectedPlayers.put(player,true);
+         if (currentState.getGameStage() == GameStages.WAITING) {
+             playersList.remove(player);
+             totemChoiceQueue.remove(player);
+             return true;
+         }
+         if(currentState.getCurrentPlayer().equals(player)) {
+             if (currentState.getGameStage() != GameStages.TOTEM_CHOICE) {
+                 nextPlayerSetup();
+                 return true;
+             }
+             else {
+                 if (totemChoiceQueue.isEmpty()) {
+                     player.setTotem(getAvailableTotems().get(new Random().nextInt(getAvailableTotems().size())));
+                 } else {
+                     totemChoiceQueue.add(player);
+                 }
+                 currentState.playerUpdate(totemChoiceQueue.poll(), null);
+                 return true;
+             }
+         }
+ 
+         return true;
+     }
+ 
+     /**
+      * Marks the specified player as reconnected.
+      *
+      * <p>If the player reconnects during the slot choice phase, they are removed
+      * from the disconnected players map and reinserted into the order logic card
+      * when necessary.
+      *
+      * @param player the player who reconnected.
+      * @return {@code true} if the reconnection is handled successfully,
+      *         {@code false} if the player was not previously marked as disconnected.
+      */
+     public synchronized boolean reconnectPlayer(Player player)
+     {
+         if(!disconnectedPlayers.containsKey(player))
+         {
+             return false;
+         }
+         disconnectedPlayers.put(player,false);
+         if(currentState.getGameStage() == GameStages.SLOT_CHOICE)
+         {
+             disconnectedPlayers.remove(player);
+             if(!orderLogicCard.containsInQueue(player))
+             {
+                 orderLogicCard.pushNoEffect(player);
+             }
+         }
+         else if(currentState.getGameStage() == GameStages.RES_ACTIONS) {
+             if(slotMap.containsValue(player))
+             {
+                 disconnectedPlayers.remove(player);
+             }
+         }
+         return true;
+     }
+ 
+     /**
+      * Clears the collection of disconnected players.
+      */
+     public synchronized void clearDisconnected()
+     {
+         disconnectedPlayers.clear();
+     }
+ 
+     /**
+      * Returns the current number of players participating in the game.
+      * @return the current number of players.
+      */
+     public int getCurrentPlayerNumber() {
+         return playersList.size();
+     }
+ 
+     /**
+      * The list of players participating in the game.
+      */
+     private ArrayList<Player> playersList;
+ 
+     /**
+      * The current state of the game.
+      */
+     private CurrentState currentState;
+ 
+     /**
+      * The mapping between slots and the players assigned to them.
+      */
+     private HashMap<Slot,Player> slotMap;
+ 
+     /**
+      * Returns the map of slots assigned to players.
+      *
+      * @return the map that associates each slot with the corresponding player.
+      */
+     public HashMap<Slot,Player> getSlotMap() {return slotMap;}
+ 
+     /**
+      * The configured number of players for this game.
+      */
+     private int nPlayers;
+ 
+     /**
+      * The queue of players involved in optional card resolution.
+      */
+     private Queue<Player> optionalCardQueue;
+ 
+     /**
+      * The order logic card associated with this game.
+      */
+     private OrderLogicCard orderLogicCard;
+ 
+     /**
+      * Returns the order logic card associated with this game.
+      *
+      * @return the order logic card.
+      */
+     public OrderLogicCard getOrderLogicCard() { return orderLogicCard; }
+ 
+     /**
+      * The board associated with this game.
+      */
+     private Board board;
+ 
+     /**
+      * Returns the game board.
+      *
+      * @return the board associated with the game.
+      */
+     public Board getBoard() {return board;}
+ 
+     /**
+      * Returns a copy of the upper tribe cards currently available on the board.
+      *
+      * @return a new list containing the upper tribe cards currently on the board.
+      */
+     public ArrayList<TribeCard> getUpperListTribeCards() {
+         return new ArrayList<>(board.getUpperListTribe());
+     }
+ 
+     /**
+      * Returns a copy of the lower tribe cards currently available on the board.
+      *
+      * @return a new list containing the lower tribe cards currently on the board.
+      */
+     public ArrayList<TribeCard> getLowerListTribeCards() {
+         return new ArrayList<>(board.getLowerListTribe());
+     }
+ 
+     /**
+      * Returns a copy of the upper building cards currently available on the board.
+      *
+      * @return a new list containing the upper building cards currently on the board.
+      */
+     public ArrayList<BuildingCard> getUpperListBuilding() {
+         return new ArrayList<>(board.getUpperListBuilding());
+     }
+ 
+     /**
+      * Returns a copy of the lower building cards currently available on the board.
+      *
+      * @return a new list containing the lower building cards currently on the board.
+      */
+     public ArrayList<BuildingCard> getLowerListBuilding() {
+         return new ArrayList<>(board.getLowerListBuilding());
+     }
+ 
+     /**
+      * Returns the current state of the game.
+      *
+      * @return the current state of the game.
+      */
+     public CurrentState getCurrentState() {
+         return currentState;
+     }
+ 
+     /**
+      * Returns the player with the specified username, if present.
+      *
+      * @param username the username of the player to search for.
+      * @return the player with the specified username, or {@code null} if no such player exists.
+      * @throws IndexOutOfBoundsException if an index access error occurs.
+      */
+     public Player getPlayerByUsername(String username) throws IndexOutOfBoundsException {
+         return playersList.stream().filter(x->x.getUserName().equals(username)).findFirst().orElse(null);
+     }
+ 
+     /**
+      * Returns the configured number of players for this game.
+      *
+      * @return the configured number of players for this game.
+      */
+     public int getNPlayers() {
+         return nPlayers;
+     }
+ 
+     /**
+      * Creates a game with the specified number of players.
+      *
+      * @param nPlayers the configured number of players for the game.
+      * @throws IllegalArgumentException if {@code nPlayers < 0} or {@code nPlayers > 5}.
+      */
+     public Game(int nPlayers) throws IllegalArgumentException{
+         if(nPlayers !=0 && (nPlayers < 2 || nPlayers > 5)) {
+             throw new IllegalArgumentException();
+         }
+         this.nPlayers = nPlayers;
+         board=new Board(nPlayers);
+         slotMap = new LinkedHashMap<>();
+         for(Slot s :board.getSlotList())
+         {
+             slotMap.put(s,null);
+         }
+         currentState= new CurrentState();
+         playersList = new ArrayList<>();
+         optionalCardQueue = new LinkedList<>();
+     }
+ 
+     /**
+      * Creates a game with 0 configured players.
+      */
+     public Game()
+     {
+         this(0);
+     }
+ 
+     /**
+      * Attempts to add the specified player to the game.
+      * The operation succeeds only if the configured number of players is not 0,
+      * the current game stage is {@code WAITING}, and the player is not already present.
+      * If the number of players reaches the configured maximum, the game is initialized.
+      *
+      * @param player the player to add to the game.
+      * @return {@code true} if the player is successfully added, {@code false} otherwise.
+      */
+     public boolean addPlayer(Player player) {
+         if(this.nPlayers==0)
+         {
+             return  false;
+         }
+         if(currentState.getGameStage()!= GameStages.WAITING)
+             return false;
+         if(getPlayerByUsername(player.getUserName())!=null)
+             return false;
+         playersList.add(player);
+         totemChoiceQueue.add(player);
+         if(playersList.size()>=nPlayers)
+         {
+             init();
+         }
+         return true;
+     }
+ 
+     /**
+      * Initializes the game after all required players have been added.
+      * The method creates the appropriate order logic card according to the number of players,
+      * selects the first current player, and updates the game stage to {@code SLOT_CHOICE}.
+      */
+     public void init() {
+ 
+         switch (nPlayers) {
+             case 2:
+                 orderLogicCard=new Order2(playersList);
+                 break;
+             case 3:
+                 orderLogicCard=new Order3(playersList);
+                 break;
+             case 4:
+                 orderLogicCard=new Order4(playersList);
+                 break;
+             case 5:
+                 orderLogicCard=new Order5(playersList);
+                 break;
+             default:
+                 throw new IllegalStateException("nPlayers must be 2–5, got: " + nPlayers);
+         }
+         for(Player player : playersList)
+         {
+             switch(orderLogicCard.getPosition(player.getUserName()))
+             {
+                 case 0: player.addFood(2); break;
+                 case 1,2: player.addFood(3); break;
+                 case 3,4: player.addFood(4); break;
+             }
+ 
+         }
+         currentState.playerUpdate(totemChoiceQueue.poll(),null);
+         currentState.gameStageUpdate(GameStages.TOTEM_CHOICE);
+     }
+ 
+     //region Controller Methods
+ 
+     /**
+      * Attempts to assign the slot at the specified index to the specified player.
+      * The operation succeeds only if the index is valid, the current game stage is {@code SLOT_CHOICE},
+      * the specified player is the current player, and the selected slot is not already assigned.
+      * If the slot is successfully assigned, the next player setup is triggered.
+      *
+      * @param player the player performing the slot choice.
+      * @param slotIndex the index of the selected slot.
+      * @return {@code true} if the slot choice succeeds, {@code false} otherwise.
+      */
+     public boolean slotChoiceByIndex(Player player, int slotIndex) {
+         if(slotIndex<0 || slotIndex>=slotMap.size())
+             return  false;
+         if(currentState.getGameStage()!= GameStages.SLOT_CHOICE)
+         {
+             return false;
+         }
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+         Map.Entry<Slot, Player> slotPlayerEntry = new ArrayList<>(slotMap.entrySet()).get(slotIndex);
+         if(slotPlayerEntry.getValue()!=null)
+         {
+             return false;
+         }
+         slotMap.put(slotPlayerEntry.getKey(),player);
+         nextPlayerSetup();
+         return true;
+ 
+     }
+ 
+     //region Drawing Methods
+ 
+     /**
+      * Attempts to draw the upper tribe card at the specified index for the specified player.
+      * The operation succeeds only if the index is valid, the game stage is {@code RESOLVING_ACTIONS},
+      * the specified player is the current player, at least one upper card draw is still available,
+      * and the selected tribe card is not an event card.
+      * If successful, the card is inserted into the player's collection, removed from the board,
+      * and the number of remaining upper draws is decremented.
+      * If both upper and lower draws become zero, the next player setup is triggered.
+      *
+      * @param player the player performing the draw.
+      * @param cardIndex the index of the upper tribe card to draw.
+      * @return {@code true} if the draw succeeds, {@code false} otherwise.
+      */
+     public boolean drawUpperTribeCardByIndex(Player player,int cardIndex) {
+         if( cardIndex<0 || cardIndex >=board.getUpperListTribe().size())
+             return false;
+         if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
+         {
+             return false;
+         }
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+         if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS)
+             return false;
+         TribeCard tribeCard = board.getUpperListTribe().get(cardIndex);
+         if(tribeCard.isEventCard())
+             return false;
+ 
+         Character tempCard = (Character) tribeCard;
+         tempCard.insert(player);
+         board.removeUpperTribeCard(tempCard);
+         if(currentState.getGameStage()==GameStages.RES_ACTIONS)
+         {
+             currentState.upperDrawn();
+             if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
+                 nextPlayerSetup();
+         }
+         else
+         {
+             nextPlayerSetup();
+         }
+ 
+         return true;
+     }
+ 
+ 
+     /**
+      * Skips the turn for the specified player when no drawable cards are available.
+      * The operation succeeds only if the current game stage is {@code RESOLVING_ACTIONS},
+      * the specified player is the current player,
+      * and the player can't draw tribe card (i.e. all remaining lower tribe cards are event cards).
+      * @param player the player skipping the turn .
+      * @return {@code true} if the skip succeeds, {@code false} otherwise.
+      */
+     public boolean skipTurn(Player player) {
+         if(currentState.getGameStage() != GameStages.RES_ACTIONS && currentState.getGameStage() != GameStages.OPT_CARD_E)
+         {
+             return false;
+         }
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+         if(currentState.getGameStage()==GameStages.RES_ACTIONS)
+         {
+             if(hasDrawableDown() && currentState.getNLower()>0 )
+                 return false;
+             if(hasDrawableUp() && currentState.getNUpper()>0)
+                 return false;
+             while(currentState.getNLower()>0)
+                 currentState.lowerDrawn();
+             while(currentState.getNUpper()>0)
+                 currentState.upperDrawn();
+             nextPlayerSetup();
+         }
+         else {
+             nextPlayerSetup();
+         }
+         return true;
+     }
+ 
+     /**
+      * Attempts to draw the lower tribe card at the specified index for the specified player.
+      * The operation succeeds only if the index is valid, the game stage is {@code RESOLVING_ACTIONS},
+      * the specified player is the current player, at least one lower card draw is still available,
+      * and the selected tribe card is not an event card.
+      * If successful, the card is inserted into the player's collection, removed from the board,
+      * and the number of remaining lower draws is decremented.
+      * If both lower and upper draws become zero, the next player setup is triggered.
+      *
+      * @param player the player performing the draw.
+      * @param cardIndex the index of the lower tribe card to draw.
+      * @return {@code true} if the draw succeeds, {@code false} otherwise.
+      */
+     public boolean drawLowerTribeCardByIndex(Player player, int cardIndex) {
+         if( cardIndex<0 || cardIndex >=board.getLowerListTribe().size())
+             return false;
+         if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
+         {
+             return false;
+         }
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+ 
+ 
+         if(currentState.getNLower() <1)
+             return false;
+         TribeCard tribeCard = board.getLowerListTribe().get(cardIndex);
+         if(tribeCard.isEventCard())
+             return false;
+ 
+         Character tempCard = (Character) tribeCard;
+         tempCard.insert(player);
+         board.removeLowerTribeCard(tempCard);
+         currentState.lowerDrawn();
+         if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
+             nextPlayerSetup();
+         return true;
+ 
+     }
+ 
+     /**
+      * Attempts to draw the upper building card at the specified index for the specified player.
+      * The operation succeeds only if the index is valid, the game stage is {@code RESOLVING_ACTIONS},
+      * the specified player is the current player, at least one upper card draw is still available,
+      * and the selected building card can be bought by the player.
+      * If successful, the building card is removed from the board and the number of remaining upper draws is decremented.
+      * If both upper and lower draws become zero, the next player setup is triggered.
+      *
+      * @param player the player performing the draw.
+      * @param cardIndex the index of the upper building card to draw.
+      * @return {@code true} if the draw succeeds, {@code false} otherwise.
+      */
+     public boolean drawUpperBuildingCardByIndex(Player player,int cardIndex) {
+         if( cardIndex<0 || cardIndex >=board.getUpperListBuilding().size())
+             return false;
+         if(currentState.getGameStage()!= GameStages.RES_ACTIONS && currentState.getGameStage()!=GameStages.OPT_CARD_E)
+         {
+             return false;
+         }
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+         BuildingCard buildingCard = board.getUpperListBuilding().get(cardIndex);
+         if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS)
+             return false;
+         if(!buildingCard.buy(player))
+         {
+             return false;
+         }
+         board.removeUpperBuildingCard(buildingCard);
+         if(currentState.getGameStage() == GameStages.RES_ACTIONS)
+         {
+             currentState.upperDrawn();
+             if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
+                 nextPlayerSetup();
+         }
+         else
+         {
+             nextPlayerSetup();
+         }
+         return true;
+     }
+ 
+     /**
+      * Attempts to draw the lower building card at the specified index for the specified player.
+      * The operation succeeds only if the index is valid, the game stage is {@code RESOLVING_ACTIONS},
+      * the specified player is the current player, at least one lower card draw is still available,
+      * and the selected building card can be bought by the player.
+      * If successful, the building card is removed from the board and the number of remaining lower draws is decremented.
+      * If both lower and upper draws become zero, the next player setup is triggered.
+      *
+      * @param player the player performing the draw.
+      * @param cardIndex the index of the lower building card to draw.
+      * @return {@code true} if the draw succeeds, {@code false} otherwise.
+      */
+     public boolean drawLowerBuildingCardByIndex(Player player,int cardIndex) {
+         if( cardIndex<0 || cardIndex >=board.getLowerListBuilding().size())
+             return false;
+         if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
+         {
+             return false;
+         }
+ 
+         if(!player.equals(currentState.getCurrentPlayer()))
+         {
+             return false;
+         }
+         BuildingCard buildingCard = board.getLowerListBuilding().get(cardIndex);
+         if(currentState.getNLower() <1)
+             return false;
+         if(buildingCard.buy(player))
+         {
+             currentState.lowerDrawn();
+             board.removeLowerBuildingCard(buildingCard);
+         }
+         else
+             return false;
+         if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty())))
+             nextPlayerSetup();
+ 
+         return true;
+ 
+     }
+ 
+ 
+     //region Optional Card Methods
+ 
+     /**
+      * Prepares the next player and updates the game state according to the current game stage.
+      * If the current stage is {@code SLOT_CHOICE}, the next player is taken from the order logic card.
+      * If no player is available, the game stage is updated to {@code RESOLVING_ACTIONS}
+      * and the first assigned slot is selected.
+      * If the current stage is {@code RESOLVING_ACTIONS}, the current player is pushed back
+      * into the order logic card, the current slot is freed, and the next assigned slot is selected.
+      * If no assigned slots remain, the game stage is updated to {@code OPTIONAL_CARD_EFFECT},
+      * the optional card queue is built from players owning building cards with effect id equal to 12,
+      * and the first player in that queue is selected.
+      * If no player is available for optional card resolution, the game stage is updated to
+      * {@code RESOLVING_EVENT}; then, if the round number is less than 10, the next round is prepared,
+      * otherwise event resolution is performed, the game stage is updated to {@code ENDING},
+      * and the game is ended.
+      * If the current stage is {@code OPTIONAL_CARD_EFFECT}, the next player is taken from the optional card queue.
+      * If no player is available, the game stage is updated to {@code RESOLVING_EVENT}.
+      */
+     private synchronized void nextPlayerSetup() {
+ 
+         if (GameStages.SLOT_CHOICE == currentState.getGameStage()) {
+             Player tempPlayer;
+             while (true) {
+                 tempPlayer = orderLogicCard.pull();
+                 if (tempPlayer == null) break;
+                 if (!disconnectedPlayers.containsKey(tempPlayer) || !disconnectedPlayers.get(tempPlayer)) break;
+             }
+             if (tempPlayer != null) {
+                 currentState.playerUpdate(tempPlayer, null);
+                 return;
+             }
+ 
+             // All players have chosen a slot → switch to RES_ACTIONS
+             currentState.gameStageUpdate(GameStages.RES_ACTIONS);
+ 
+             boolean anyAssigned = false;
+             for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
+                 if (entry.getValue() != null) {
+                     if(entry.getKey().getSlotId()=='A')
+                     {
+                         entry.getValue().addFood(3);
+                         orderLogicCard.push(entry.getValue());
+                         entry.setValue(null);
+                         continue;
+                     }
+                     currentState.playerUpdate(entry.getValue(), entry.getKey());
+                     boolean hasDrawableLower = currentState.getNLower() > 0
+                             && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
+                     boolean hasDrawableUpper = currentState.getNUpper() > 0
+                             && (hasDrawableUp() || !getUpperListBuilding().isEmpty());
+                     if (!hasDrawableLower && !hasDrawableUpper) {
+                         // This player has nothing drawable, skip them immediately
+                         orderLogicCard.push(currentState.getCurrentPlayer());
+                         slotMap.put(currentState.getSlot(), null);
+                     } else {
+                         anyAssigned = true;
+                         break;
+                     }
+                 }
+             }
+ 
+             // If every player was skipped, jump straight to optional phase
+             if (!anyAssigned) {
+                 transitionToOptionalOrNextRound();
+             }
+ 
+             return;
+         }
+ 
+         if (GameStages.RES_ACTIONS == currentState.getGameStage()) {
+             orderLogicCard.push(currentState.getCurrentPlayer());
+             slotMap.put(currentState.getSlot(), null);
+ 
+             for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
+                 if (entry.getValue() != null) {
+                     if(disconnectedPlayers.containsKey(entry.getValue())&& disconnectedPlayers.get(entry.getValue()))
+                     {
+                         orderLogicCard.push(entry.getValue());
+                         entry.setValue(null);
+                         continue;
+                     }
+                     currentState.playerUpdate(entry.getValue(), entry.getKey());
+                     boolean hasDrawableLower = currentState.getNLower() > 0
+                             && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
+                     boolean hasDrawableUpper = currentState.getNUpper() > 0
+                             && (hasDrawableUp() || !getUpperListBuilding().isEmpty());
+                     if (!hasDrawableLower && !hasDrawableUpper) {
+                         // This player also has nothing, skip and continue the loop
+                         orderLogicCard.push(entry.getValue());
+                         entry.setValue(null);
+                     } else {
+                         // Found a player with something to do, stop here
+                         return;
+                     }
+                 }
+             }
+ 
+             // All slots are now null → every player is done for this round
+             transitionToOptionalOrNextRound();
+             return;
+         }
+ 
+         if (GameStages.OPT_CARD_E == currentState.getGameStage()) {
+             Player optionalPlayer = optionalCardQueue.poll();
+ 
+             if (optionalPlayer != null) {
+                 currentState.playerUpdate(optionalPlayer, null);
+                 if(disconnectedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnectedPlayers.get(currentState.getCurrentPlayer())) {
+                     nextPlayerSetup();
+                 }
+                 return;
+             }
+ 
+             currentState.gameStageUpdate(GameStages.RES_EVENT);
+ 
+             if (currentState.getRound() < 10) {
+                 nextRound();
+                 currentState.playerUpdate(orderLogicCard.pull(), null);
+                 currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
+             } else {
+                 currentState.gameStageUpdate(GameStages.ENDING);
+                 endGame();
+             }
+         }
+     }
+     /**
+      * Transitions the game to the optional card phase or directly to the next round.
+      *
+      * <p>Builds a queue of non-disconnected players who own Building 12 (optional card effect).
+      * If such players exist, the first one is set as the current player for their optional action.
+      * Otherwise, if the round counter is below 10, the next round begins and the game stage
+      * is set to {@link GameStages#SLOT_CHOICE}; if round 10 has been completed, the game ends.
+      */
+     private synchronized void transitionToOptionalOrNextRound() {
+         currentState.gameStageUpdate(GameStages.OPT_CARD_E);
+ 
+         optionalCardQueue = new LinkedList<>();
+         for (Player p :playersList) {
+             long count = p.getBuildingCards().stream().filter(x -> x.getEffectId() == 12).count();
+             if (count > 0) {
+                 if(disconnectedPlayers.containsKey(p)&& disconnectedPlayers.get(p))
+                 {
+                     continue;
+                 }
+                 optionalCardQueue.add(p);
+             }
+         }
+ 
+         Player optionalPlayer = optionalCardQueue.poll();
+ 
+         if (optionalPlayer != null) {
+             currentState.playerUpdate(optionalPlayer, null);
+             return;
+         }
+ 
+         if (currentState.getRound() < 10) {
+             nextRound();
+             for (Map.Entry<Player, Boolean> entry : new ArrayList<>(disconnectedPlayers.entrySet())) {
+                 if (!entry.getValue()) {
+                     orderLogicCard.pushNoEffect(entry.getKey());
+                     disconnectedPlayers.remove(entry.getKey());
+                 } else {
+                     orderLogicCard.removeFromQueue(entry.getKey());
+                 }
+             }
+             currentState.playerUpdate(orderLogicCard.pull(), null);
+             currentState.gameStageUpdate(GameStages.SLOT_CHOICE);
+         } else {
+             currentState.gameStageUpdate(GameStages.ENDING);
+             endGame();
+         }
+     }
+     /**
+      * Checks whether there are any drawable upper tribe cards on the board,
+      * i.e. upper tribe cards that are not event cards.
+      *
+      * @return {@code true} if at least one non-event upper tribe card is available, {@code false} otherwise.
+      */
+     private boolean hasDrawableUp()
+     {
+         return getUpperListTribeCards().stream().anyMatch(x -> !x.isEventCard());
+     }
+ 
+     /**
+      * Checks whether there are any drawable lower tribe cards on the board,
+      * i.e. lower tribe cards that are not event cards.
+      *
+      * @return {@code true} if at least one non-event lower tribe card is available, {@code false} otherwise.
+      */
+     private boolean hasDrawableDown()
+     {
+         return getLowerListTribeCards().stream().anyMatch(x -> !x.isEventCard());
+     }
+     /**
+      * Resolves all pending event cards if the current game stage is {@code RESOLVING_EVENT}.
+      * All pending events are activated on the player list.
+      * Event cards of type {@code SUSTENANCE} are resolved after all other pending events.
+      */
+     private void eventResolution() {
+ 
+         currentState.gameStageUpdate(GameStages.RES_EVENT);
+         Queue<EventCard> events;
+         events=board.getPendingEvents();
+         ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new));
+         events.removeAll(sustenance);
+         for(EventCard event:events)
+         {
+             event.activateEvent(playersList);
+         }
+ 
+         for(EventCard e : sustenance)
+         {
+             e.activateEvent(playersList);
+         }
+ 
+     }
+ 
+ 
+     /**
+      * Advances the game to the next round.
+      * The method first resolves pending events.
+      * If the current round is 10, the game stage is updated to {@code ENDING} and the game is ended.
+      * Otherwise, the era is updated if the board changes era, and the round number is incremented.
+      */
+     private void nextRound() {
+ 
+         eventResolution();
+         if(currentState.getEra()!= board.nextRound())  {
+             currentState.eraUpdate();
+         }
+ 
+         currentState.roundUpdate();
+ 
+     }
+ 
+     /**
+      * Ends the game by applying all final building effects owned by each player
+      * and updating the game stage to {@code ENDED}.
+      */
+     private void endGame() {
+         Queue<EventCard> events;
+         events=Stream.concat(board.getLowerListTribe().stream().filter(TribeCard::isEventCard),board.getUpperListTribe().stream().filter(TribeCard::isEventCard)).map(x->((EventCard)x)).collect(Collectors.toCollection(LinkedList::new));
+         ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new));
+         events.removeAll(sustenance);
+         events.forEach(event->event.activateEvent(playersList));
+         sustenance.forEach(event->event.activateEvent(playersList));
+ 
+         playersList.forEach(p->{
+             int temp= p.getBuilders().stream().mapToInt(Builder::getPrestigeValue).sum();
+             p.addPrestige(temp);
+         });
+         playersList.forEach(p->{
+             int temp=(int) p.getInventors().stream().mapToInt(Inventor::getIcon).distinct().count();
+             p.addPrestige(temp*p.getNType(CharacterType.INVENTOR));
+         });
+         playersList.forEach(p->{
+             p.addPrestige(10 * (p.getNType(CharacterType.ARTIST)/2));
+         });
+         playersList.forEach(p->{
+             int temp= p.getBuildingCards().stream().mapToInt(BuildingCard::getPrestigeValue).sum();
+             p.addPrestige(temp);
+         });
+         playersList.forEach(
+             p -> p.getBuildingCards().stream().filter(x -> x.getEffectType() == EffectType.FINAL).
+             forEach(x -> x.applyEffect(p))
+         );
+         currentState.gameStageUpdate(GameStages.ENDED);
+         playerStanding=new ArrayList<>(playersList);
+         playerStanding.sort((y,x)->x.getPrestigeValue()==y.getPrestigeValue()?Integer.compare(x.getFoodValue(),y.getFoodValue()):Integer.compare(x.getPrestigeValue(),y.getPrestigeValue()));
+ 
+     }
+ 
+     /**
+      * Sets the configured number of players for this game.
+      * The operation succeeds only if the current configured number of players is 0.
+      *
+      * @param nPlayers the new configured number of players.
+      * @return {@code true} if the number of players is updated, {@code false} otherwise.
+      */
+     public boolean setNPlayer(int nPlayers) {
+         if (this.nPlayers != 0) {
+             return false;
+         }
+ 
+         if (nPlayers < 2 || nPlayers > 5) {
+             return false;
+         }
+ 
+         this.nPlayers = nPlayers;
+ 
+         board = new Board(nPlayers);
+ 
+         slotMap = new LinkedHashMap<>();
+         for (Slot s : board.getSlotList()) {
+             slotMap.put(s, null);
+         }
+ 
+         currentState = new CurrentState();
+         playersList = new ArrayList<>();
+         optionalCardQueue = new LinkedList<>();
+ 
+         return true;
+     }
+ 
+     /**
+      * Ends the game by forfeit and determines the final player standing.
+      *
+      * <p>The player who is still connected is declared the winner and placed
+      * in the first position of the final ranking. The remaining players are
+      * ordered by prestige value and, in case of a tie, by food value.
+      */
+     public synchronized void endGameForfeit() {
+         Player winner = playersList.stream()
+                 .filter(x -> !disconnectedPlayers.containsKey(x) || !disconnectedPlayers.get(x))
+                 .findFirst().orElse(null);
+         if (winner == null) return;
+         currentState.gameStageUpdate(GameStages.ENDED);
+         playerStanding = new ArrayList<>(playersList);
+         playerStanding.remove(winner);
+         playerStanding.sort((y, x) -> x.getPrestigeValue() == y.getPrestigeValue()
+                 ? Integer.compare(x.getFoodValue(), y.getFoodValue())
+                 : Integer.compare(x.getPrestigeValue(), y.getPrestigeValue()));
+         playerStanding.add(0, winner);
+     }
+ 
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-3.html new file mode 100644 index 0000000..8d790da --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-3.html @@ -0,0 +1,413 @@ + + + + + + + + Coverage Report > MiniModel + + + + + + +
+ + +

Coverage Summary for Class: MiniModel (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
MiniModel + + 0% + + + (0/1) + + + + 0% + + + (0/21) + + + + 0% + + + (0/14) + + + + 0% + + + (0/44) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.GamePackage.Board;
+ import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.io.Serializable;
+ import java.util.*;
+ 
+ /**
+  * Lightweight representation of the game model shared with clients.
+  *
+  * <p>The mini model contains only the information required by the client-side
+  * view and controllers to render the current match state and process incoming
+  * network updates.
+  */
+ public class MiniModel implements Serializable {
+ 
+     /** Upper row of tribe cards currently on the board. */
+     public ArrayList<TribeCard> upperListTribeCards;
+     /** Lower row of tribe cards currently on the board. */
+     public ArrayList<TribeCard> lowerListTribeCards;
+     /** Upper row of building cards currently on the board. */
+     public ArrayList<BuildingCard> upperListBuildingCards;
+     /** Lower row of building cards currently on the board. */
+     public ArrayList<BuildingCard> lowerListBuildingCards;
+     /** Usernames of players currently disconnected from the game. */
+     public ArrayList<String> disconnectedPlayers;
+     /** The most recent network event applied to this model. */
+     public NetworkEvent lastEvent;
+ 
+     /**
+      * Map associating each occupied slot with the corresponding player.
+      */
+     public Map<Slot, Player> slotPlayerMap;
+ 
+     /**
+      * Card used to manage the player turn order.
+      */
+     public OrderLogicCard orderLogicCard;
+ 
+     /**
+      * Current state of the game.
+      */
+     public CurrentState currentState;
+ 
+     /**
+      * Map of players indexed by username.
+      */
+     public Map<String, Player> players;
+ 
+     /**
+      * List of totems still available for selection.
+      */
+     public List<Totems> availableTotems;
+ 
+     /**
+      * Final standing of the players at the end of the game.
+      */
+     public List<Player> standingPlayers;
+ 
+     /**
+      * Constructs an empty mini model.
+      */
+     public MiniModel() {
+     }
+ 
+     /**
+      * Constructs a mini model with only the card lists populated.
+      *
+      * @param upperListTribeCards  the upper row of tribe cards on the board.
+      * @param lowerListTribeCards  the lower row of tribe cards on the board.
+      * @param upperListBuildingCards the upper row of building cards on the board.
+      * @param lowerListBuildingCards the lower row of building cards on the board.
+      */
+     public MiniModel(ArrayList<TribeCard> upperListTribeCards,ArrayList<TribeCard>lowerListTribeCards,ArrayList<BuildingCard> upperListBuildingCards,ArrayList<BuildingCard>lowerListBuildingCards) {
+         this.upperListTribeCards = upperListTribeCards;
+         this.lowerListTribeCards = lowerListTribeCards;
+         this.upperListBuildingCards = upperListBuildingCards;
+         this.lowerListBuildingCards = lowerListBuildingCards;
+         this.disconnectedPlayers = new ArrayList<>();
+     }
+ 
+     /**
+      * Constructs a complete mini model from the current server-side game data.
+      *
+      * @param slotPlayerMap          the map associating occupied slots with players.
+      * @param orderLogicCard         the card managing player turn order.
+      * @param currentState           the current state of the game.
+      * @param players                the list of players in the match.
+      * @param availableTotems        the list of totems still available for selection.
+      * @param upperListTribeCards    the upper row of tribe cards on the board.
+      * @param lowerListTribeCards    the lower row of tribe cards on the board.
+      * @param upperListBuildingCards the upper row of building cards on the board.
+      * @param lowerListBuildingCards the lower row of building cards on the board.
+      * @param disconnectedPlayers    the list of usernames of currently disconnected players.
+      */
+     public MiniModel(Map<Slot, Player> slotPlayerMap,
+                      OrderLogicCard orderLogicCard,
+                      CurrentState currentState,
+                      List<Player> players,
+                      List<Totems> availableTotems,ArrayList<TribeCard> upperListTribeCards,ArrayList<TribeCard>lowerListTribeCards,ArrayList<BuildingCard> upperListBuildingCards,ArrayList<BuildingCard>lowerListBuildingCards, ArrayList<String> disconnectedPlayers) {
+ 
+         this.slotPlayerMap = slotPlayerMap;
+         this.orderLogicCard = orderLogicCard;
+         this.currentState = currentState;
+         this.players = new LinkedHashMap<>();
+         this.availableTotems = availableTotems;
+         this.standingPlayers = new ArrayList<>();
+         this.upperListTribeCards = upperListTribeCards;
+         this.lowerListTribeCards = lowerListTribeCards;
+         this.upperListBuildingCards = upperListBuildingCards;
+         this.lowerListBuildingCards = lowerListBuildingCards;
+         this.disconnectedPlayers = disconnectedPlayers;
+         setPlayers(players);
+     }
+ 
+     /**
+      * Sets the last network event applied to the game state.
+      *
+      * @param lastEvent the most recent event received from the server.
+      */
+     public void setLastEvent(NetworkEvent lastEvent) {
+         this.lastEvent = lastEvent;
+     }
+ 
+ 
+     /**
+      * Sets the list of totems still available for selection.
+      *
+      * @param availableTotems the available totems.
+      */
+     public void setAvailableTotems(List<Totems> availableTotems) {
+         this.availableTotems = availableTotems;
+     }
+ 
+     /**
+      * Sets the map associating occupied slots with players.
+      *
+      * @param slotPlayerMap the slot-player map to assign.
+      */
+     public void setSlotPlayerMap(Map<Slot, Player> slotPlayerMap) {
+         this.slotPlayerMap = slotPlayerMap;
+     }
+ 
+     /**
+      * Sets the card used to manage the player turn order.
+      *
+      * @param orderLogicCard the order logic card to assign.
+      */
+     public void setOrderLogicCard(OrderLogicCard orderLogicCard) {
+         this.orderLogicCard = orderLogicCard;
+     }
+ 
+     /**
+      * Sets the current state of the game.
+      *
+      * @param currentState the current game state.
+      */
+     public void setCurrentState(CurrentState currentState) {
+         this.currentState = currentState;
+     }
+ 
+     /**
+      * Replaces or updates the players stored in the mini model.
+      *
+      * <p>Each player is indexed by username.
+      *
+      * @param players the list of players to store.
+      */
+     public void setPlayers(List<Player> players) {
+         for (Player player : players) {
+             this.players.put(player.getUserName(), player);
+         }
+     }
+ 
+     /**
+      * Adds or updates a single player in the mini model.
+      *
+      * @param player the player to store.
+      */
+     public void setPlayer(Player player) {
+         players.put(player.getUserName(), player);
+     }
+ 
+     /**
+      * Sets the final standing of the players.
+      *
+      * @param standingPlayers the final ordered list of players.
+      */
+     public void setStandingPlayers(List<Player> standingPlayers) {
+         this.standingPlayers = standingPlayers;
+     }
+ 
+     /**
+      * Replaces the upper row of tribe cards on the board.
+      *
+      * @param cards the new upper tribe card list.
+      */
+     public void setUpperListTribeCards(ArrayList<TribeCard> cards) {
+         this.upperListTribeCards = cards;
+     }
+ 
+     /**
+      * Replaces the lower row of tribe cards on the board.
+      *
+      * @param cards the new lower tribe card list.
+      */
+     public void setLowerListTribeCards(ArrayList<TribeCard> cards) {
+         this.lowerListTribeCards = cards;
+     }
+ 
+     /**
+      * Replaces the upper row of building cards on the board.
+      *
+      * @param cards the new upper building card list.
+      */
+     public void setUpperListBuildingCards(ArrayList<BuildingCard> cards) {
+         this.upperListBuildingCards = cards;
+     }
+ 
+     /**
+      * Replaces the lower row of building cards on the board.
+      *
+      * @param cards the new lower building card list.
+      */
+     public void setLowerListBuildingCards(ArrayList<BuildingCard> cards) {
+         this.lowerListBuildingCards = cards;
+     }
+ 
+     /**
+      * Removes the card at the given position from the upper tribe card list.
+      *
+      * @param pos the zero-based index of the card to remove.
+      */
+     public void removeUpperTribeCard(int pos) {
+         if (upperListTribeCards != null) upperListTribeCards.remove(pos);
+     }
+ 
+     /**
+      * Removes the card at the given position from the lower tribe card list.
+      *
+      * @param pos the zero-based index of the card to remove.
+      */
+     public void removeLowerTribeCard(int pos) {
+         if (lowerListTribeCards != null) lowerListTribeCards.remove(pos);
+     }
+ 
+     /**
+      * Removes the card at the given position from the upper building card list.
+      *
+      * @param pos the zero-based index of the card to remove.
+      */
+     public void removeUpperBuildingCard(int pos) {
+         if (upperListBuildingCards != null) upperListBuildingCards.remove(pos);
+     }
+ 
+     /**
+      * Removes the card at the given position from the lower building card list.
+      *
+      * @param pos the zero-based index of the card to remove.
+      */
+     public void removeLowerBuildingCard(int pos) {
+         if (lowerListBuildingCards != null) lowerListBuildingCards.remove(pos);
+     }
+ 
+     /**
+      * Returns the position of the player with the specified username
+      * within the player collection.
+      *
+      * @param username the username of the player to search for.
+      * @return the zero-based position of the player, or {@code -1}
+      *         if no matching username is found.
+      */
+     public int getPositionByUsername(String username) {
+         int i = 0;
+         for (Player player : players.values()) {
+             if (player.getUserName().equals(username)) {
+                 return i;
+             }
+             i++;
+         }
+         return -1;
+     }
+ 
+     /**
+      * Sets the list of usernames of currently disconnected players.
+      *
+      * @param disconnectedPlayers the list of disconnected player usernames.
+      */
+     public void setDisconnectedPlayers (ArrayList<String> disconnectedPlayers){
+         this.disconnectedPlayers=disconnectedPlayers;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-4.html new file mode 100644 index 0000000..3f426b7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-4.html @@ -0,0 +1,297 @@ + + + + + + + + Coverage Report > OrderLogicCard + + + + + + +
+ + +

Coverage Summary for Class: OrderLogicCard (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderLogicCard + + 100% + + + (1/1) + + + + 80% + + + (8/10) + + + + 91.7% + + + (11/12) + + + + 87.1% + + + (27/31) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.io.Serializable;
+ import java.util.*;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * Abstract base class for all order logic cards.
+  *
+  * <p>An order logic card manages the turn order of the players and defines
+  * the behavior used to update the order during the game.
+  */
+ public abstract class OrderLogicCard implements Serializable {
+ 
+     /**
+      * The queue of {@link Player Players} associated with this order logic card.
+      */
+     private Queue<Player> players;
+ 
+     /**
+      * The list of {@link OrderPlayer} entries tracking turn order and played status.
+      * Protected so subclasses can read it for display purposes (e.g., {@link #toString()}).
+      */
+     protected List<OrderPlayer> playerList;
+ 
+     /**
+      * Returns an unmodifiable view of the player order list.
+      *
+      * @return the list of {@link OrderPlayer} entries in turn order.
+      */
+     public List<OrderPlayer> getPlayerList() {
+         return Collections.unmodifiableList(playerList);
+     }
+ 
+     /** Total number of players in this game. */
+     protected final int nPlayers;
+ 
+ 
+     /**
+      * Creates an order logic card with the specified list of players.
+      *
+      * <p>The input list is shuffled in place to establish a random initial turn order.
+      * This is intentional: the caller's list (typically {@code Game.playersList}) is
+      * reordered so that the game's canonical player sequence reflects the randomised order.
+      *
+      * @param players the list of players associated with this order logic card.
+      *                <strong>The list is mutated (shuffled) by this constructor.</strong>
+      */
+     public OrderLogicCard(ArrayList<Player> players) {
+         Collections.shuffle(players);
+         this.players = new LinkedList<>(players);
+         nPlayers = players.size();
+         this.playerList = new ArrayList<>(players.stream().map(x -> new OrderPlayer(x, false)).toList());
+     }
+ 
+     /**
+      * Applies the effect associated with the current queue position of the player
+      * and then adds the player to the end of the queue.
+      *
+      * @param player the player to be pushed into the queue.
+      */
+     public void push(Player player) {
+         effect(player, players.size());
+         if (players.size() == 0) {
+             playerList.clear();
+         }
+         playerList.add(new OrderPlayer(player, false));
+         players.add(player);
+     }
+ 
+     /**
+      * Moves the specified player to the end of the queue without applying effects.
+      *
+      * <p>Any previous occurrence of the player is removed from both the queue
+      * and the order list before the player is added again.
+      *
+      * @param player the player to be pushed into the queue.
+      */
+     public void pushNoEffect(Player player) {
+         players.removeIf(x -> player.getUserName().equals(x.getUserName()));
+         playerList.removeIf(x -> player.getUserName().equals(x.getPlayer().getUserName()));
+         playerList.add(new OrderPlayer(player, false));
+         players.add(player);
+     }
+ 
+     /**
+      * Removes and returns the first player in the queue.
+      *
+      * <p>The first order entry that has not yet been marked as played
+      * is marked as played before removing the player from the queue.
+      *
+      * @return the first player in the queue, or {@code null} if the queue is empty.
+      */
+     public Player pull() {
+         for (OrderPlayer p : playerList) {
+             if (!p.isPlayed()) {
+                 p.markAsPlayed();
+                 break;
+             }
+         }
+         return players.poll();
+     }
+ 
+     /**
+      * Returns the first player in the queue without removing it.
+      *
+      * @return the first player in the queue, or {@code null} if the queue is empty.
+      */
+     public Player getFirst()
+     {
+         return players.peek();
+     }
+ 
+     /**
+      * Applies the effect associated with the specified player and queue position.
+      *
+      * @param player the player to whom the effect is applied.
+      * @param index the queue position index associated with the effect.
+      * @throws IndexOutOfBoundsException if the specified index is not valid.
+      */
+     protected abstract void effect(Player player, int index) throws IndexOutOfBoundsException;
+ 
+     /**
+      * Applies the building-related effect to the specified player.
+      * For each building card owned by the player with effect id equal to 3,
+      * the player gains 1 Food.
+      *
+      * @param player the player to whom the building effect is applied.
+      */
+     protected void buildingEffect(Player player) {
+         long count = player.getBuildingCards().stream().filter(x -> x.getEffectId() == 3).count();
+         player.addFood((int) count);
+     }
+ 
+     /**
+      * Returns whether the given player is currently present in the turn queue.
+      *
+      * @param player the player to look up.
+      * @return {@code true} if the player is in the queue; {@code false} otherwise.
+      */
+     public boolean containsInQueue(Player player) {
+         return players.contains(player);
+     }
+ 
+     /**
+      * Removes the given player from both the turn queue and the order list.
+      * No-op if the player is not present.
+      *
+      * @param player the player to remove.
+      */
+     public void removeFromQueue(Player player) {
+         players.removeIf(x -> x.equals(player));
+         playerList.removeIf(x -> x.getPlayer().equals(player));
+     }
+ 
+     /**
+      * Returns the position of the player associated with the specified username
+      * within the current order list.
+      *
+      * @param username the username of the player whose position is requested.
+      * @return the player's position, or {@code -1} if no player with the specified
+      *         username is present in the order list.
+      * @see Player
+      */
+     public int getPosition(String username) {
+         int pos = 0;
+         for (OrderPlayer p : playerList) {
+             if (p.getPlayer().getUserName().equals(username))
+                 return pos;
+             pos++;
+         }
+         return -1;
+     }
+ 
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-5.html new file mode 100644 index 0000000..402a335 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-5.html @@ -0,0 +1,204 @@ + + + + + + + + Coverage Report > PlayableCard + + + + + + +
+ + +

Coverage Summary for Class: PlayableCard (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
PlayableCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (8/8) + + + + 100% + + + (14/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ import java.io.Serializable;
+ 
+ 
+ /**
+  * Abstract base class for all playable cards.
+  * A PlayableCard is characterized by an era value.
+  */
+ public abstract class PlayableCard implements Serializable {
+ 
+     /**
+      * The image identifier of the playable card.
+      */
+     private String idIMG;
+ 
+     /**
+      * Returns the image identifier of this playable card.
+      *
+      * @return the image identifier of this playable card.
+      */
+     public String getIdIMG() {
+         return idIMG;
+     }
+ 
+     /**
+      * The era associated with this playable card.
+      */
+     private int era;
+ 
+     /**
+      * Returns the era of this playable card.
+      *
+      * @return the era of this playable card.
+      */
+     public int getEra(){
+         return era;
+     }
+ 
+     /**
+      * Creates a playable card with the specified era.
+      *
+      * @param era the era of the playable card.
+      * @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
+      */
+     public PlayableCard(int era) throws IllegalArgumentException {
+         idIMG = "-1";
+         if (era > 0 && era < 4) {
+             this.era = era;
+         } else {
+             throw new IllegalArgumentException();
+         }
+     }
+ 
+     /**
+      * Creates a playable card with the specified image id and era.
+      *
+      * @param idIMG the image identifier of the playable card.
+      * @param era the era of the playable card.
+      * @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
+      */
+     public PlayableCard(String idIMG, int era) throws IllegalArgumentException {
+         this.idIMG = idIMG;
+         if (era > 0 && era < 4) {
+             this.era = era;
+         } else {
+             throw new IllegalArgumentException();
+         }
+     }
+ 
+     /**
+      * Returns a string representation of this playable card.
+      *
+      * @return a string representation of this playable card.
+      */
+     @Override
+     public String toString() {
+         return "";
+     }
+ 
+     /**
+      * Returns a compact string representation used when rendering the board in the TUI.
+      *
+      * @return a compact board representation of this card.
+      */
+     public String toStringBoard() {
+         return ":";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-6.html new file mode 100644 index 0000000..f89fecd --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-6.html @@ -0,0 +1,503 @@ + + + + + + + + Coverage Report > Player + + + + + + +
+ + +

Coverage Summary for Class: Player (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Class + Method, % + + Branch, % + + Line, % +
Player + + 100% + + + (22/22) + + + + 96.6% + + + (56/58) + + + + 100% + + + (105/105) + +
Player$1 + + 100% + + + (1/1) + + + + 100% + + + (1/1) + +
Total + + 100% + + + (23/23) + + + + 96.6% + + + (56/58) + + + + 100% + + + (106/106) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ 
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.Map;
+ import java.util.stream.Collectors;
+ 
+ import static it.polimi.ingsw.gc14.View.TUI.BorderStyle.*;
+ 
+ /**
+  * Default Player class; contains all identifiers and methods needed.
+  */
+ public class Player implements Serializable {
+     /**
+      * The maximum length allowed for the username string.
+      */
+     private static final int MAX_USERNAME_LENGTH = 32;
+ 
+     /**
+      * Identifier for the {@code Player} when displaying the game through the GUI.
+      * @see Totems
+      */
+     private Totems totem;
+ 
+     // region Getters
+     /**
+      * Unique string identifier for players; must not be {@code null} and must not
+      * exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
+      * when the {@link #Player(String) constructor} is called.
+      */
+     private final String userName;
+ 
+     /**
+      * Getter for the private attribute {@link #userName}.
+      * @return {@code String} - The UserName
+      */
+     public String getUserName() {
+         return userName;
+     }
+ 
+     /**
+      * Returns the totem assigned to this player.
+      *
+      * @return this player's totem.
+      */
+     public Totems getTotem() {
+         return totem;
+     }
+ 
+     /**
+      * Counts the total {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character Character Cards}
+      * the player currently possesses.
+      * @return {@code int} - Total Character Cards.
+      */
+     public int getTotCharacters() {
+         return Arrays.stream(CharacterType.values())
+                 .mapToInt(this::getNType)
+                 .sum();
+     }
+ 
+     /**
+      * Counts the total number of cards of the specified {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType Character Type}.
+      * Character Type must not be {@code null}
+      * @param type the Character Type to be Counted.
+      * @return {@code int} - Total number of cards of given {@code type}.
+      */
+     public int getNType(CharacterType type) {
+         return switch (type) {
+             case ARTIST -> artists.size();
+             case INVENTOR -> inventors.size();
+             case HUNTER -> hunters.size();
+             case BUILDER -> builders.size();
+             case SHAMAN -> shamans.size();
+             case GATHERER -> gatherers.size();
+         };
+     }
+     private ArrayList<BuildingCard> buildingCards;
+     private ArrayList<Artist> artists;
+     private ArrayList<Builder> builders;
+     private ArrayList<Inventor> inventors;
+     private ArrayList<Gatherer> gatherers;
+     private ArrayList<Shaman> shamans;
+     private ArrayList<Hunter> hunters;
+ 
+     /** @return this player's building cards. */
+     public ArrayList<BuildingCard> getBuildingCards() { return buildingCards; }
+     /** @return this player's Artist character cards. */
+     public ArrayList<Artist> getArtists() { return artists; }
+     /** @return this player's Builder character cards. */
+     public ArrayList<Builder> getBuilders() { return builders; }
+     /** @return this player's Inventor character cards. */
+     public ArrayList<Inventor> getInventors() { return inventors; }
+     /** @return this player's Gatherer character cards. */
+     public ArrayList<Gatherer> getGatherers() { return gatherers; }
+     /** @return this player's Shaman character cards. */
+     public ArrayList<Shaman> getShamans() { return shamans; }
+     /** @return this player's Hunter character cards. */
+     public ArrayList<Hunter> getHunters() { return hunters; }
+ 
+     /**
+      * The current amount of {@code Food} the Player possesses.
+      * Cannot be negative.
+      */
+     private int foodValue;
+ 
+     /**
+      * Getter for the private attribute {@link #foodValue}.
+      * @return {@code int} - The amount of Food the player possesses.
+      */
+     public int getFoodValue() {
+         return foodValue;
+     }
+ 
+     /**
+      * The current amount of {@code Prestige} the Player possesses.
+      */
+     private int prestigeValue;
+ 
+     /**
+      * Getter for the private attribute {@link #prestigeValue}.
+      * @return {@code int} - The amount of Prestige the Player possesses.
+      */
+     public int getPrestigeValue() {
+         return prestigeValue;
+     }
+ 
+     // endregion getters
+ 
+     // region Setters
+ 
+     /**
+      * Adds {@code value} amount of Food to the Player.
+      * @param value The amount of Food to be added. Should be non-negative.
+      * @see #foodValue
+      */
+     public void addFood(int value){
+         this.foodValue += value;
+     }
+ 
+     /**
+      * Sets the totem for this player.
+      *
+      * @param totem the totem to assign.
+      */
+     public void setTotem(Totems totem) {
+         this.totem = totem;
+     }
+ 
+     /**
+      * Removes {@code value} amount of Food from the Player.
+      * {@link #foodValue} cannot go negative: returns {@code false} if
+      * {@code value} exceeds the current food and leaves the value unchanged.
+      *
+      * @param value The amount of Food to be removed. Should be non-negative.
+      * @return {@code true} if the Food is successfully removed, {@code false} otherwise.
+      * @see #foodValue
+      */
+     public boolean removeFood(int value){
+         if(value > this.foodValue){
+             return false;
+         }
+         this.foodValue -= value;
+         return true;
+     }
+ 
+     /**
+      * Adds {@code value} amount of Prestige to the Player.
+      * @param value The amount of Prestige to be added. Should be non-negative.
+      * @see #prestigeValue
+      */
+     public void addPrestige(int value){
+         this.prestigeValue += value;
+     }
+ 
+     /**
+      * Removes {@code value} amount of Prestige from the Player.
+      * @param value The amount of Prestige to be removed. Should be non-negative.
+      * @see #prestigeValue
+      */
+     public void removePrestige(int value){
+         this.prestigeValue -= value;
+     }
+ 
+     // endregion setters
+ 
+     // region Constructors
+ 
+     /**
+      * Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #userName}.
+      *
+      * @param userName Unique String identifier for a Player.
+      * @throws IllegalArgumentException when {@code userName} is empty or exceeds {@link #MAX_USERNAME_LENGTH},
+      *                                  with message:
+      *                                  <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre>
+      *
+      * @see #userName
+      * @see #MAX_USERNAME_LENGTH
+      */
+     public Player(String userName) throws  IllegalArgumentException {
+         if(userName.isEmpty() || userName.length() > MAX_USERNAME_LENGTH) {
+             throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");
+         }
+         this.userName = userName;
+ 
+         this.inventors = new ArrayList <>();
+         this.builders = new ArrayList <>();
+         this.gatherers = new ArrayList <>();
+         this.shamans = new ArrayList <>();
+         this.hunters = new ArrayList <>();
+         this.artists = new ArrayList<>();
+ 
+         this.buildingCards = new ArrayList<>();
+         this.foodValue = 0;
+         this.prestigeValue = 0;
+         this.totem = null;
+     }
+     // endregion constructors
+ 
+     // region Functions
+ 
+     // TODO
+     @Override
+     public boolean equals(Object obj) {
+         if (this == obj) return true;
+         if (!(obj instanceof Player)) return false;
+         return userName.equals(((Player) obj).userName);
+     }
+ 
+     @Override
+     public int hashCode() {
+         return userName.hashCode();
+     }
+ 
+     /**
+      * Prints the {@code Player}'s attributes for the {@code Board}'s representation.
+      * Uses the {@code UNICODE} border style.
+      * <p><b>Includes:</b>
+      * <li>{@link #foodValue Food}
+      * <li>{@link #prestigeValue Prestige}
+      * <li>{@link #artists Artists}
+      * <li>{@link #builders Builders}
+      * <li>{@link #gatherers Gatherers}
+      * <li>{@link #shamans Shamans}
+      * <li>{@link #inventors Inventors}
+      * <li>{@link #hunters Hunters}
+      * <li>{@link #buildingCards Buildings}
+      * </p>
+      * @return {@code String} - A string representation of the {@code Player}'s attributes.
+      * @see it.polimi.ingsw.gc14.View.TUI.BorderStyle BorderStyle
+      */
+     @Override
+     public String toString() {
+         int last = -1;
+ 
+         var table = new AsciiTable(ROUNDED, 1);
+ 
+         String totemStr = (this.totem != null) ? " (" + this.totem.toString() + ")" : "";
+         table.addHeader(this.getUserName() + totemStr + "  |  \uD83C\uDF56:" + this.getFoodValue() + "  |  \uD83C\uDFC5:" + this.getPrestigeValue());
+         table.addSeparator();
+ 
+         if(!this.hunters.isEmpty()){
+             last = 6;
+         }
+         else if(!this.inventors.isEmpty()){
+             last = 5;
+         }
+         else if(!this.shamans.isEmpty()){
+             last = 4;
+         }
+         else if(!this.gatherers.isEmpty()){
+             last = 3;
+         }
+         else if(!this.builders.isEmpty()){
+             last = 2;
+         }
+         else if(!this.artists.isEmpty()){
+             last = 1;
+         }
+         else{
+             last = 0;
+         }
+ 
+         if(last == 0){
+             table.addSeparator();
+         }
+         table.addRow("CHARACTERS");
+         if(!this.artists.isEmpty()){
+             table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());
+             if(last == 1){
+                 table.addSeparator();
+             }
+         }
+ 
+         if(!this.builders.isEmpty()){
+             table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());
+             if(last == 2){
+                 table.addSeparator();
+             }
+         }
+ 
+         if(!this.gatherers.isEmpty()){
+             table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size());
+             if(last == 3){
+                 table.addSeparator();
+             }
+         }
+ 
+         if(!this.shamans.isEmpty()){
+             table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum());
+             if(last == 4){
+                 table.addSeparator();
+             }
+         }
+ 
+         if(!this.inventors.isEmpty()){
+             table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream()
+                     .collect(Collectors.groupingBy(
+                             Inventor::getIcon,
+                             Collectors.counting()
+                     ))
+                     .entrySet().stream()
+                     .sorted(Map.Entry.comparingByKey())
+                     .map(e -> e.getKey() + ":" + e.getValue())
+                     .collect(Collectors.joining(", ")));
+             if(last == 5){
+                 table.addSeparator();
+             }
+         }
+ 
+ 
+         if(!this.hunters.isEmpty()){
+             table.addRow(this.hunters.size() + " Hunters: \uD83C\uDF56" + this.hunters.stream().filter(Hunter::getIcon).count());
+             table.addSeparator();
+         }
+         table.addSeparator();
+         table.addRow("BUILDING CARDS" +
+                 (this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum() != 0
+                         ? " 🏅:" + this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum()
+                         : ""));
+         if(!this.buildingCards.isEmpty()){
+             table.addRow(this.buildingCards.size() + " Buildings: " + this.buildingCards.stream().map(BuildingCard::toStringPlayer).collect(Collectors.joining(", ")));
+         }
+ 
+         return table.build();
+     }
+     // endregion functions
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-7.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-7.html new file mode 100644 index 0000000..56730f2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-7.html @@ -0,0 +1,312 @@ + + + + + + + + Coverage Report > Slot + + + + + + +
+ + +

Coverage Summary for Class: Slot (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Slot + + 100% + + + (1/1) + + + + 90% + + + (9/10) + + + + 42.1% + + + (8/19) + + + + 82.2% + + + (37/45) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ import java.io.Serializable;
+ 
+ /**
+  * Represents a slot with a specific identifier and associated values
+  * for upper cards, lower cards, food, and minimum number of players.
+  * The slot configuration depends on the specified slot identifier.
+  */
+ public class Slot implements Serializable {
+     // Getters
+ 
+     /**
+      * The identifier of this slot.
+      */
+     private char slotId;
+ 
+     /**
+      * Returns the identifier of this slot.
+      *
+      * @return the identifier of this slot.
+      */
+     public char getSlotId() {
+         return slotId;
+     }
+ 
+     /**
+      * The number of upper cards associated with this slot.
+      */
+     private int nUpper;
+     /**
+      * Returns the number of upper cards associated with this slot.
+      *
+      * @return the number of upper cards associated with this slot.
+      */
+     public int getNUpper(){
+         return nUpper;
+     }
+ 
+     /**
+      * The minimum number of players required for this slot.
+      */
+     private int nMinPlayer;
+ 
+     /**
+      * Returns the minimum number of players required for this slot.
+      *
+      * @return the minimum number of players required for this slot.
+      */
+     public int getNMinPlayer()
+     {
+         return nMinPlayer;
+     }
+ 
+     /**
+      * The number of lower cards associated with this slot.
+      */
+     private int nLower;
+ 
+     /**
+      * Returns the number of lower cards associated with this slot.
+      *
+      * @return the number of lower cards associated with this slot.
+      */
+     public int getNLower(){
+         return nLower;
+     }
+ 
+     /**
+      * The amount of Food associated with this slot.
+      */
+     private int food;
+ 
+     /**
+      * Returns the amount of Food associated with this slot.
+      *
+      * @return the amount of Food associated with this slot.
+      */
+     public int getFood(){
+         return food;
+     }
+     // End getters
+ 
+     // Constructors
+ 
+     /**
+      * Creates a slot with the specified identifier.
+      * The slot values for Food, NLower, NUpper, and minimum number of players
+      * are determined by the given slot identifier.
+      *
+      * @param slotId the identifier of the slot.
+      * @throws IllegalArgumentException if the specified slot identifier is not valid.
+      */
+     public Slot(char slotId) throws IllegalArgumentException
+     {
+         this.slotId = slotId;
+         this.nMinPlayer=0;
+         switch(slotId)
+         {
+             case 'A':
+                 this.food = 3;
+                 this.nLower = 0;
+                 this.nUpper = 0;
+                 this.nMinPlayer=5;
+                 break;
+             case 'B':
+                 this.food = 0;
+                 this.nLower = 1;
+                 this.nUpper = 0;
+                 break;
+             case 'C':
+                 this.food = 0;
+                 this.nLower = 0;
+                 this.nUpper = 1;
+                 break;
+             case 'D':
+                 this.food = 0;
+                 this.nLower = 2;
+                 this.nUpper = 0;
+                 this.nMinPlayer = 3;
+                 break;
+             case 'E':
+                 this.food = 0;
+                 this.nLower = 1;
+                 this.nUpper = 1;
+                 break;
+             case 'F':
+                 this.food = 0;
+                 this.nLower = 0;
+                 this.nUpper = 2;
+                 break;
+             case 'G':
+                 this.food = 0;
+                 this.nLower = 1;
+                 this.nUpper = 2;
+                 this.nMinPlayer = 4;
+                 break;
+             default:
+                 throw new IllegalArgumentException();
+         }
+     }
+ 
+ 
+     /**
+      * Returns the string representation of this slot.
+      * The returned string includes the slot identifier, number of upper cards,
+      * number of lower cards, food value, and minimum number of players.
+      *
+      * @return the string representation of this slot.
+      */
+     @Override
+     public String toString() {
+         return ("SlotID: "+this.getSlotId()+"\nNUpper: "+this.getNUpper()+"\nNLower: "+this.getNLower()+"\nFood: "+this.getFood()+"\n");
+     }
+ 
+ 
+     /**
+      * Returns a compact string representation of this {@code Slot} for the TUI.
+      * <p>Includes:
+      * <ul>
+      * <li>{@link #slotId}</li>
+      * <li>{@link #nUpper} (shown as ▲ symbols)</li>
+      * <li>{@link #nLower} (shown as ▼ symbols)</li>
+      * <li>{@link #food} (if non-zero)</li>
+      * </ul>
+      * @return a compact TUI string representation of this {@code Slot}.
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     public String toStringTUI()
+     {
+         StringBuilder  s = new StringBuilder(" ");
+         for(int i=0;i<this.getNUpper();i++) s.append("▲");
+         for(int i=0;i<this.getNLower();i++) s.append("▼");
+         if(getFood()!=0) s.append("+"+getFood()+" \uD83C\uDF56");
+         s.append(" ");
+         return s.toString();
+     }
+ 
+     // Functions
+ 
+     // TODO
+     @Override
+     public boolean equals(Object obj) {
+         if (this == obj) return true;
+         if (!(obj instanceof Slot)) return false;
+         return slotId == ((Slot) obj).slotId;
+     }
+ 
+     // TODO
+     @Override
+     public int hashCode() {
+         return Character.hashCode(slotId);
+     }
+ 
+     // End functions
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-3/sources/source-8.html b/deliverables/Coverage/htmlReport/ns-3/sources/source-8.html new file mode 100644 index 0000000..988217f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-3/sources/source-8.html @@ -0,0 +1,136 @@ + + + + + + + + Coverage Report > Totems + + + + + + +
+ + +

Coverage Summary for Class: Totems (it.polimi.ingsw.gc14.Model)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Totems + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (6/6) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model;
+ 
+ /**
+  * Represents the different totem colors available in the game.
+  */
+ public enum Totems {
+ 
+     /**
+      * Yellow totem.
+      */
+     YELLOW,
+ 
+     /**
+      * Blue totem.
+      */
+     BLUE,
+ 
+     /**
+      * Orange totem.
+      */
+     ORANGE,
+ 
+     /**
+      * White totem.
+      */
+     WHITE,
+ 
+     /**
+      * Purple totem.
+      */
+     PURPLE
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index.html b/deliverables/Coverage/htmlReport/ns-4/index.html new file mode 100644 index 0000000..4a21c00 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..a9a6126 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..d2cedca --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..9876ce7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..aa1f29f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE.html new file mode 100644 index 0000000..6377122 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..a5be4fb --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..fc06fa0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..e7453e8 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..e674113 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,195 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards + + 100% + + + (2/2) + + + + 100% + + + (20/20) + + + + 100% + + + (25/25) + + + + 100% + + + (58/58) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (11/11) + +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-4/sources/source-1.html new file mode 100644 index 0000000..c0b7424 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/sources/source-1.html @@ -0,0 +1,365 @@ + + + + + + + + Coverage Report > BuildingCard + + + + + + +
+ + +

Coverage Summary for Class: BuildingCard (it.polimi.ingsw.gc14.Model.Cards)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
BuildingCard + + 100% + + + (1/1) + + + + 100% + + + (14/14) + + + + 100% + + + (25/25) + + + + 100% + + + (47/47) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.BuildingEffect;
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.PlayableCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ import java.io.Serializable;
+ 
+ /**
+  * Represents a generic building card in the game.
+  *
+  * <p>A building card is a playable card with a price and a specific building
+  * effect. Concrete building cards extend this class to define their own
+  * behavior.
+  */
+ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEffect, Serializable {
+ 
+     /**
+      * The price of this building card.
+      */
+     private int price;
+ 
+     /**
+      * Returns the price of this building card.
+      *
+      * @return the price of this building card.
+      */
+     public int getPrice() {
+         return price;
+     }
+ 
+     /**
+      * Indicates whether this building card has already been bought.
+      */
+     private boolean bought;
+ 
+     /**
+      * The type of effect associated with this building card.
+      */
+     protected EffectType effectType;
+ 
+     /**
+      * The identifier of the effect associated with this building card.
+      */
+     protected int effectId;
+ 
+     /**
+      * The prestige value of this building card.
+      */
+     private int prestigeValue;
+ 
+     /**
+      * Returns the prestige value of this building card.
+      *
+      * @return the prestige value of this building card.
+      */
+     public int  getPrestigeValue() {
+         return prestigeValue;
+     }
+ 
+     /**
+      * Returns the identifier of the effect associated with this building card.
+      *
+      * @return the effect identifier of this building card.
+      */
+     public int getEffectId() {
+         return effectId;
+     }
+ 
+     /**
+      * Returns the type of effect associated with this building card.
+      *
+      * @return the effect type of this building card.
+      */
+     public EffectType getEffectType() {
+         return effectType;
+     }
+ 
+     /**
+      * Creates a building card with the specified era, price, and prestige value.
+      *
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @throws IllegalArgumentException if {@code price <= 0} or {@code prestigeValue < 0}
+      */
+     protected BuildingCard(int era,int price,int prestigeValue) throws IllegalArgumentException{
+         super(era);
+         if (price > 0) {
+             this.price = price;
+         } else {
+             throw new IllegalArgumentException();
+         }
+         if (prestigeValue >= 0) {
+             this.prestigeValue = prestigeValue;
+         } else {
+             throw new IllegalArgumentException();
+         }
+ 
+         bought = false;
+     }
+ 
+     /**
+      * Creates a building card with the specified image identifier, era, price,
+      * and prestige value.
+      *
+      * @param idIMG the image identifier of the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @throws IllegalArgumentException if {@code price <= 0} or {@code prestigeValue < 0}
+      */
+     protected BuildingCard(String idIMG,int era,int price,int prestigeValue) throws IllegalArgumentException{
+         super(idIMG,era);
+         if (price > 0) {
+             this.price = price;
+         } else {
+             throw new IllegalArgumentException();
+         }
+         if (prestigeValue >= 0) {
+             this.prestigeValue = prestigeValue;
+         } else {
+             throw new IllegalArgumentException();
+         }
+ 
+         bought = false;
+     }
+ 
+ 
+     /**
+      * Creates a building card with the specified effect identifier, era, price,
+      * and prestige value.
+      * The effect type is determined from the given effect identifier.
+      *
+      * @param effectId the identifier of the effect associated with the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @throws IllegalArgumentException if the effect identifier is not valid,
+      *         if {@code price <= 0}, or if {@code prestigeValue < 0}
+      */
+     public BuildingCard(int effectId, int era, int price, int prestigeValue) throws IllegalArgumentException {
+         this(era, price, prestigeValue);
+         this.effectType = effectTypeFromId(effectId);
+         this.effectId = effectId;
+     }
+ 
+     /**
+      * Creates a building card with the specified image id, effect identifier, era,
+      * price, and prestige value.
+      *
+      * <p>The effect type is determined from the given effect identifier.
+      *
+      * @param idIMG the image identifier of the building card.
+      * @param effectId the identifier of the effect associated with the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @throws IllegalArgumentException if the effect identifier is not valid,
+      *                                  if {@code price <= 0}, or if {@code prestigeValue < 0}.
+      */
+     public BuildingCard(String idIMG, int effectId, int era, int price, int prestigeValue) throws IllegalArgumentException {
+         this(idIMG, era, price, prestigeValue);
+         this.effectType = effectTypeFromId(effectId);
+         this.effectId = effectId;
+     }
+ 
+     private static EffectType effectTypeFromId(int effectId) {
+         switch (effectId) {
+             case 2: return EffectType.ON_EVENT;
+             case 3: return EffectType.ON_END_TURN;
+             case 5: return EffectType.ON_EVENT;
+             case 6: return EffectType.ON_EVENT;
+             case 7: return EffectType.ON_EVENT;
+             case 9: return EffectType.ON_EVENT;
+             case 12: return EffectType.ON_ROUND_END;
+             default: throw new IllegalArgumentException();
+         }
+     }
+ 
+     /**
+      * Creates and returns a copy of this building card.
+      *
+      * @return a clone of this building card.
+      */
+     @Override
+     public BuildingCard clone()
+     {
+         return new BuildingCard(getIdIMG(),effectId,getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Attempts to buy this building card for the specified player.
+      *
+      * <p>The effective cost is reduced by the total reduction value provided
+      * by the player's Builder cards, without dropping below zero. The purchase
+      * succeeds only if the card has not already been bought and the player can
+      * pay the resulting amount of Food. If successful, the card is added to
+      * the player's building cards and marked as bought.
+      *
+      * @param player the player attempting to buy the building card.
+      * @return {@code true} if the building card is successfully bought,
+      *         {@code false} otherwise.
+      */
+     public boolean buy(Player player) {
+         int discount = player.getBuilders().stream().mapToInt(x -> x.getReductionValue()).sum();
+ 
+         if(discount > this.price){
+             discount = this.price;
+         }
+ 
+         if(bought || !player.removeFood(this.price - discount))
+             return false;
+         player.getBuildingCards().add(this);
+         bought=true;
+         return true;
+     }
+ 
+     /**
+      * Default implementation of the building effect.
+      *
+      * <p>This method does not perform any operation and can be overridden
+      * by specific building cards that define an active effect.
+      *
+      * @param player the player to whom the effect may be applied.
+      */
+     @Override
+     public void applyEffect(Player player) {}
+ 
+     /**
+      * Returns the string representation of this building card.
+      *
+      * @return the string representation of this building card.
+      */
+     @Override
+     public String toString() {
+         return ":" + " ID:" + getEffectId() + " \uD83C\uDF56:" + getPrice() + " \uD83C\uDFC5:" + getPrestigeValue();
+     }
+ 
+     /**
+      * Returns a compact player-view string representation of this building card.
+      *
+      * @return a compact string showing the effect identifier.
+      */
+     public String toStringPlayer() {
+         return "ID:" + getEffectId();
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-4/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-4/sources/source-2.html new file mode 100644 index 0000000..7d1d206 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-4/sources/source-2.html @@ -0,0 +1,206 @@ + + + + + + + + Coverage Report > TribeCard + + + + + + +
+ + +

Coverage Summary for Class: TribeCard (it.polimi.ingsw.gc14.Model.Cards)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
TribeCard + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (11/11) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.PlayableCard;
+ import java.io.Serializable;
+ 
+ 
+ /**
+  * Abstract base class for all tribe cards.
+  * A TribeCard is a {@link PlayableCard} that may either be an event card
+  * or a non-event card, and may optionally specify a minimum number of players.
+  */
+ public abstract class TribeCard extends PlayableCard implements Serializable {
+ 
+     /**
+      * Indicates whether this tribe card is an event card.
+      */
+     private boolean isEventCard;
+ 
+     /**
+      * Returns whether this tribe card is an event card.
+      *
+      * @return {@code true} if this card is an event card, {@code false} otherwise.
+      */
+     public boolean isEventCard() {
+         return isEventCard;
+     }
+ 
+     /**
+      * The minimum number of players required for this tribe card.
+      */
+     private int nMin=0;
+ 
+     /**
+      * Returns the minimum number of players required for this tribe card.
+      *
+      * @return the minimum number of players required for this tribe card.
+      */
+     public int getNMin() {
+         return nMin;
+     }
+ 
+     /**
+      * Creates a tribe card with the specified era and event-card flag.
+      * The minimum number of players is set to 0.
+      *
+      * @param Era the era of the tribe card.
+      * @param isEventCard whether the card is an event card.
+      */
+     public TribeCard(int Era,boolean isEventCard) {
+         this(Era,isEventCard,0);
+     }
+ 
+     /**
+      * Creates a tribe card with the specified image id, era and event-card flag.
+      * The minimum number of players is set to 0.
+      *
+      * @param idIMG the image identifier of the tribe card.
+      * @param Era the era of the tribe card.
+      * @param isEventCard whether the card is an event card.
+      */
+     public TribeCard(String idIMG,int Era,boolean isEventCard) {
+         this(idIMG,Era,isEventCard,0);
+     }
+ 
+     /**
+      * Creates a tribe card with the specified era, event-card flag,
+      * and minimum number of players.
+      *
+      * @param Era the era of the tribe card.
+      * @param isEventCard whether the card is an event card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public TribeCard(int Era,boolean isEventCard,int nMin) {
+         super(Era);
+         this.nMin=nMin;
+         this.isEventCard=isEventCard;
+     }
+ 
+     /**
+      * Creates a tribe card with the specified image id, era, event-card flag,
+      * and minimum number of players.
+      *
+      * @param idIMG the image identifier of the tribe card.
+      * @param Era the era of the tribe card.
+      * @param isEventCard whether the card is an event card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public TribeCard(String idIMG, int Era,boolean isEventCard,int nMin) {
+         super(idIMG,Era);
+         this.nMin=nMin;
+         this.isEventCard=isEventCard;
+     }
+ 
+     /**
+      * Creates and returns a copy of this tribe card.
+      *
+      * @return a clone of this tribe card.
+      */
+     @Override
+     public abstract TribeCard clone();
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index.html b/deliverables/Coverage/htmlReport/ns-5/index.html new file mode 100644 index 0000000..5f52376 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..92d3a2f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..d875eb6 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..62e93f3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..7d8219b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE.html new file mode 100644 index 0000000..5476d43 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..c81778d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..e682203 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..dee6c6b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..ece7c13 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,143 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-5/sources/source-1.html new file mode 100644 index 0000000..8342b06 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/sources/source-1.html @@ -0,0 +1,141 @@ + + + + + + + + Coverage Report > EffectType + + + + + + +
+ + +

Coverage Summary for Class: EffectType (it.polimi.ingsw.gc14.Model.Cards.Building)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
EffectType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building;
+ 
+  /**
+  * Represents the possible effect types of building cards.
+  */
+ public enum EffectType {
+ 
+      /**
+       * Effect applied during the final scoring phase.
+       */
+      FINAL,
+ 
+      /**
+       * Effect based on collecting a specific set of cards.
+       */
+      CARD_SET,
+ 
+      /**
+       * Effect based on pairs of Inventor cards.
+       */
+      INVENTOR_PAIR,
+ 
+      /**
+       * Effect triggered when an event card is resolved.
+       */
+      ON_EVENT,
+ 
+      /**
+       * Effect triggered at the end of a player's turn.
+       */
+      ON_END_TURN,
+ 
+      /**
+       * Effect triggered at the end of a round.
+       */
+      ON_ROUND_END
+  }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-5/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-5/sources/source-2.html new file mode 100644 index 0000000..6661877 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-5/sources/source-2.html @@ -0,0 +1,87 @@ + + + + + + + + Coverage Report > BuildingEffect + + + + + + +
+ + +

Coverage Summary for Class: BuildingEffect (it.polimi.ingsw.gc14.Model.Cards.Building)

+ + + + + + + + + +
Class
BuildingEffect
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building;
+ 
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Defines the effect behavior of a building card.
+  *
+  * <p>Classes implementing this interface provide the specific effect
+  * applied to a player when the building card is activated.
+  */
+ public interface BuildingEffect {
+ 
+     /**
+      * Applies the building effect to the specified player.
+      *
+      * @param player the player affected by the building effect.
+      */
+     void applyEffect(Player player);
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index.html b/deliverables/Coverage/htmlReport/ns-6/index.html new file mode 100644 index 0000000..8519850 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..30aec78 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..a6b0b80 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..2cf71b7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..4609d66 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE.html new file mode 100644 index 0000000..aedb385 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..79aa9ea --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..1f22342 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..468ad96 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..a0f80ff --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,370 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.Building.Effects

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.Building.Effects + + 100% + + + (7/7) + + + + 100% + + + (38/38) + + + + 92% + + + (46/50) + + + + 100% + + + (129/129) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (12/12) + +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-1.html new file mode 100644 index 0000000..dc79fd5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-1.html @@ -0,0 +1,264 @@ + + + + + + + + Coverage Report > Building0 + + + + + + +
+ + +

Coverage Summary for Class: Building0 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building0 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 81.2% + + + (13/16) + + + + 100% + + + (30/30) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ 
+ 
+ 
+ /**
+  * Building effect that grants 5 food for each new complete set of
+  * 6 different character types obtained after purchasing this building.
+  *
+  * <p>Character sets already completed before the building is purchased
+  * are stored during initialization and do not provide food.
+  */
+ public class Building0 extends BuildingCard {
+ 
+     /** Food units granted per newly completed character set. */
+     private static final int FOOD_PER_CHARACTER_SET = 5;
+ 
+     /**
+      * Indicates whether the building effect has already been initialized
+      * after purchase.
+      */
+     private boolean purchased;
+ 
+     /**
+      * Number of complete character sets already counted by this building effect.
+      */
+     private int numSet;
+ 
+     /**
+      * Creates a building with the specified image identifier, era, price
+      * and prestige value.
+      *
+      * @param idImage the image identifier of the building.
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points granted by this building
+      *                      at the end of the game.
+      */
+     public Building0(String idImage,int era,int price,int prestigeValue) {
+         super(idImage,era,price,prestigeValue);
+         effectType=EffectType.CARD_SET;
+         effectId=0;
+         purchased = false;
+         numSet = 0;
+     }
+ 
+     /**
+      * Creates a building with the specified era, price and prestige value.
+      *
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points granted by this building
+      *                      at the end of the game.
+      */
+     public Building0(int era,int price,int prestigeValue) {
+         super(era,price,prestigeValue);
+         effectType=EffectType.CARD_SET;
+         effectId=0;
+         purchased = false;
+         numSet = 0;
+     }
+ 
+     /**
+      * Attempts to purchase the building and initializes its effect if the
+      * purchase succeeds.
+      *
+      * @param player the player who attempts to buy the building.
+      * @return {@code true} if the building is successfully purchased and initialized,
+      *         {@code false} otherwise.
+      */
+     @Override
+     public boolean buy(Player player)
+     {
+         if(!super.buy(player))
+             return false;
+         initialize(player);
+         return true;
+     }
+ 
+     /**
+      * Initializes the building effect by storing the number of complete
+      * character sets already owned by the player at the moment of purchase.
+      *
+      * <p>The initialization is performed only once.
+      *
+      * @param player the player who owns the building.
+      */
+     public void initialize(Player player)
+     {
+         if(purchased)
+         {
+             return;
+         }
+         numSet=player.getNType(CharacterType.INVENTOR);
+         for(CharacterType type : CharacterType.values())
+         {
+             if(player.getNType(type)<=numSet)
+                 numSet=player.getNType(type);
+         }
+         purchased = true;
+     }
+ 
+     /**
+      * Creates a new building instance with the same configuration values
+      * as this card.
+      *
+      * <p>The runtime state of the effect, such as initialization status and
+      * counted character sets, is not copied.
+      *
+      * @return a new building card with the same base properties.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building0(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Applies the building effect to the specified player.
+      *
+      * <p>The method counts the complete character sets currently owned by the player
+      * and grants 5 food for each set completed since the last stored value.
+      *
+      * @param player the player who owns the building.
+      * @throws IllegalArgumentException if the specified player does not own this card.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         int min_temp=player.getNType(CharacterType.INVENTOR);
+         for(CharacterType type : CharacterType.values())
+         {
+             if(player.getNType(type)<=min_temp)
+                 min_temp=player.getNType(type);
+         }
+         if(min_temp<=numSet)
+         {
+             return;
+         }
+         player.addFood(FOOD_PER_CHARACTER_SET *(min_temp-numSet));
+         numSet=min_temp;
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-2.html new file mode 100644 index 0000000..3198d2f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-2.html @@ -0,0 +1,189 @@ + + + + + + + + Coverage Report > Building1 + + + + + + +
+ + +

Coverage Summary for Class: Building1 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Building1 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (12/12) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ 
+ /**
+  * Building effect that grants a discount of 1 food during the Sustenance Event
+  * for each character of the indicated type present in the player's tribe.
+  */
+ public class Building1 extends BuildingCard {
+ 
+     /**
+      * Character type involved in the building effect.
+      */
+     private CharacterType icon ;
+ 
+     /**
+      * Returns the character type associated with this building effect.
+      *
+      * @return the character type associated with this building effect.
+      */
+     public CharacterType getIcon() {return icon;}
+ 
+     /**
+      * Creates a building with the specified era, price, prestige value
+      * and character type involved in its effect.
+      *
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
+      * @param icon the character type used by the building effect.
+      */
+     public Building1(int era, int price,int prestigeValue, CharacterType icon) {
+         super(era,price,prestigeValue);
+         effectType = EffectType.ON_EVENT;
+         effectId = 1;
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a building with the specified image identifier, era, price,
+      * prestige value and character type involved in its effect.
+      *
+      * @param idIMG the image identifier of the building.
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
+      * @param icon the character type used by the building effect.
+      */
+     public Building1(String idIMG,int era, int price,int prestigeValue, CharacterType icon) {
+         super(idIMG,era,price,prestigeValue);
+         effectType = EffectType.ON_EVENT;
+         effectId = 1;
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a new building instance with the same configuration values
+      * as this card.
+      *
+      * @return a new building card with the same base properties and icon.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building1(getIdIMG(),getEra(),getPrice(),getPrestigeValue(),getIcon());
+     }
+ 
+     /**
+      * Returns a string representation of this building, including the character
+      * type associated with its effect.
+      *
+      * @return a string representation of this building.
+      */
+     @Override
+     public String toString() {
+         return super.toString() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
+     }
+ 
+     // TODO
+     @Override
+     public String toStringPlayer() {
+         return super.toStringPlayer() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-3.html new file mode 100644 index 0000000..5301985 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-3.html @@ -0,0 +1,197 @@ + + + + + + + + Coverage Report > Building10 + + + + + + +
+ + +

Coverage Summary for Class: Building10 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building10 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (6/6) + + + + 100% + + + (14/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ 
+ /**
+  * At the end of the game, the player gains 6 Prestige Points
+  * for each complete set of character types in their tribe.
+  *
+  * <p>A complete set contains one character card of each {@link CharacterType}.
+  */
+ public class Building10 extends BuildingCard {
+ 
+     /** Prestige points granted per complete character set at end of game. */
+     private static final int PRESTIGE_PER_CHARACTER_SET = 6;
+ 
+     /**
+      * Creates a Building10 card with the specified era, price, and prestige value.
+      *
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      */
+     public Building10(int era, int price,int prestigeValue) {
+         super(era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=10;
+     }
+ 
+     /**
+      * Creates a Building10 card with the specified image id, era, price, and prestige value.
+      *
+      * @param idIMG the image identifier of the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      */
+     public Building10(String idIMG,int era, int price,int prestigeValue) {
+         super(idIMG,era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=10;
+     }
+ 
+     /**
+      * Creates and returns a copy of this Building10 card.
+      *
+      * @return a clone of this Building10 card.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building10(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Applies the effect of this building card to the specified player.
+      *
+      * <p>The effect grants 6 Prestige Points for each complete set of character
+      * cards owned by the player, where a complete set contains one card of each
+      * {@link CharacterType}.
+      *
+      * @param player the player to whom the effect is applied.
+      * @throws IllegalArgumentException if the player does not own this building card.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         int numSet=player.getNType(CharacterType.INVENTOR);
+         for(CharacterType type : CharacterType.values())
+         {
+             if(player.getNType(type)<=numSet)
+                 numSet=player.getNType(type);
+         }
+ 
+         player.addPrestige(PRESTIGE_PER_CHARACTER_SET * numSet);
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-4.html new file mode 100644 index 0000000..004ed29 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-4.html @@ -0,0 +1,235 @@ + + + + + + + + Coverage Report > Building11 + + + + + + +
+ + +

Coverage Summary for Class: Building11 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building11 + + 100% + + + (1/1) + + + + 100% + + + (8/8) + + + + 100% + + + (2/2) + + + + 100% + + + (18/18) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * At the end of the game, the player gains Prestige Points based on the number
+  * of cards of the indicated character type in their tribe.
+  *
+  * <p>The gained amount is equal to the number of matching character cards
+  * multiplied by the building's prestige multiplier.
+  */
+ public class Building11 extends BuildingCard {
+ 
+     /**
+      * The character type involved in this building effect.
+      */
+     private CharacterType characterType;
+ 
+     /**
+      * Returns the CharacterType associated with this building card effect.
+      *
+      * @return the CharacterType associated with this building card effect.
+      */
+     public CharacterType getIcon() { return characterType; }
+ 
+     /**
+      * The prestige multiplier applied per matching character card at end of game.
+      */
+     private int prestigeMul;
+ 
+     /**
+      * Returns the prestige multiplier associated with this building card effect.
+      *
+      * @return the prestige multiplier associated with this building card effect.
+      */
+     public int getPrestigeMul() {return prestigeMul;}
+ 
+     /**
+      * Creates a Building11 card with the specified era, price, prestige value,
+      * character type icon, and prestige multiplier.
+      *
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @param icon the CharacterType associated with the building card effect.
+      * @param prestigeMul the prestige multiplier of the building card effect.
+      */
+     public Building11(int era, int price,int prestigeValue, CharacterType  icon, int prestigeMul) {
+         super(era,price,prestigeValue);
+         effectType = EffectType.FINAL;
+         effectId = 11;
+         this.characterType = icon;
+         this.prestigeMul = prestigeMul;
+     }
+ 
+     /**
+      * Creates a Building11 card with the specified image id, era, price, prestige value,
+      * character type icon, and prestige multiplier.
+      *
+      * @param idIMG the image identifier of the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      * @param icon the CharacterType associated with the building card effect.
+      * @param prestigeMul the prestige multiplier of the building card effect.
+      */
+     public Building11(String idIMG,int era, int price,int prestigeValue, CharacterType  icon, int prestigeMul) {
+         super(idIMG,era,price,prestigeValue);
+         effectType = EffectType.FINAL;
+         effectId = 11;
+         this.characterType = icon;
+         this.prestigeMul = prestigeMul;
+     }
+ 
+     /**
+      * Creates and returns a copy of this Building11 card.
+      *
+      * @return a clone of this Building11 card.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul());
+     }
+ 
+     /**
+      * Applies the effect of this building card to the specified player.
+      * The effect grants prestige points equal to the number of cards of the
+      * associated CharacterType owned by the player, multiplied by the prestige multiplier.
+      *
+      * @param player the player to whom the effect is applied.
+      * @throws IllegalArgumentException if the player does not own this building card.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul());
+     }
+ 
+     /**
+      * Returns a string representation of this {@code Building11}, including the
+      * character type associated with its effect and its prestige multiplier.
+      *
+      * @return a string representation of this {@code Building11}.
+      */
+     @Override
+     public String toString() {
+         return super.toString() + "+" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul;
+     }
+ 
+     // TODO
+     @Override
+     public String toStringPlayer() {
+         return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul + ")";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-5.html new file mode 100644 index 0000000..b8df533 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-5.html @@ -0,0 +1,183 @@ + + + + + + + + Coverage Report > Building13 + + + + + + +
+ + +

Coverage Summary for Class: Building13 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building13 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (2/2) + + + + 100% + + + (10/10) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * At the end of the game, this building grants 25 Prestige Points
+  * to the player who owns it.
+  */
+ public class Building13 extends BuildingCard{
+ 
+     /** Prestige points granted at end of game by this building. */
+     private static final int PRESTIGE_AWARD = 25;
+ 
+     /**
+      * Creates a Building13 card with the specified era, price, and prestige value.
+      *
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      */
+     public Building13(int era, int price,int prestigeValue) {
+         super(era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=13;
+     }
+ 
+     /**
+      * Creates a Building13 card with the specified image id, era, price, and prestige value.
+      *
+      * @param idIMG the image identifier of the building card.
+      * @param era the era of the building card.
+      * @param price the price of the building card.
+      * @param prestigeValue the prestige value of the building card.
+      */
+     public Building13(String idIMG,int era, int price,int prestigeValue) {
+         super(idIMG,era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=13;
+     }
+ 
+     /**
+      * Creates and returns a copy of this Building13 card.
+      *
+      * @return a clone of this Building13 card.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building13(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Applies the effect of this building card to the specified player,
+      * granting 25 Prestige Points.
+      *
+      * @param player the player to whom the effect is applied.
+      * @throws IllegalArgumentException if the player does not own this building card.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         player.addPrestige(PRESTIGE_AWARD);
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-6.html new file mode 100644 index 0000000..139b32a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-6.html @@ -0,0 +1,274 @@ + + + + + + + + Coverage Report > Building4 + + + + + + +
+ + +

Coverage Summary for Class: Building4 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building4 + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 95% + + + (19/20) + + + + 100% + + + (34/34) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ import java.util.HashMap;
+ 
+ /**
+  * Building effect that grants 3 food for each new pair of identical inventors
+  * obtained after purchasing this building.
+  *
+  * <p>Pairs of identical inventors already owned at the moment of purchase
+  * are stored during initialization and do not provide food.
+  */
+ public class Building4 extends BuildingCard {
+ 
+     /** Food units granted per newly completed inventor pair. */
+     private static final int FOOD_PER_INVENTOR_PAIR = 3;
+ 
+     /**
+      * Indicates whether the building effect has already been initialized
+      * after purchase.
+      */
+     private boolean purchased;
+ 
+     /**
+      * Number of inventor pairs already counted by this building effect.
+      */
+     private int numPair;
+ 
+     /**
+      * Creates a building with the specified era, price and prestige value.
+      *
+      * @param era The game era of the building.
+      * @param price The price (in food) of the building.
+      * @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
+      */
+     public Building4(int era, int price,int prestigeValue) {
+         super(era,price,prestigeValue);
+         effectType= EffectType.INVENTOR_PAIR;
+         effectId=4;
+     }
+ 
+     /**
+      * Creates a building with the specified image identifier, era, price
+      * and prestige value.
+      *
+      * @param idIMG the image identifier of the building.
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
+      */
+     public Building4(String idIMG,int era, int price,int prestigeValue) {
+         super(idIMG,era,price,prestigeValue);
+         effectType= EffectType.INVENTOR_PAIR;
+         effectId=4;
+     }
+ 
+     /**
+      * Initializes the building effect by storing the number of pairs of identical
+      * inventors already owned by the player at the moment of purchase.
+      *
+      * <p>The initialization is performed only once.
+      *
+      * @param player the player who owns the building.
+      */
+     public void initialize(Player player)
+     {
+         if(purchased)
+         {
+             return;
+         }
+         HashMap<Integer,Integer> map = new HashMap<>();
+         for(int i=0;i<10;i++)
+         {
+             map.put(i,0);
+         }
+         for(Inventor inv : player.getInventors())
+         {
+             map.merge(inv.getIcon(),1,Integer::sum);
+         }
+         numPair=0;
+         for(Integer i : map.values())
+         {
+             numPair+=(i/2);
+         }
+         purchased = true;
+ 
+     }
+ 
+     /**
+      * Attempts to purchase the building and initializes its effect if the
+      * purchase succeeds.
+      *
+      * @param player The player who buys the building.
+      * @return {@code true} if the building is successfully purchased and initialized,
+      *         {@code false} otherwise.
+      */
+     @Override
+     public boolean buy(Player player)
+     {
+         if(!super.buy(player))
+             return false;
+         initialize(player);
+         return true;
+     }
+ 
+     /**
+      * Creates a new building instance with the same configuration values
+      * as this card.
+      *
+      * <p>The runtime state of the effect, such as initialization status and
+      * counted inventor pairs, is not copied.
+      *
+      * @return a new building card with the same base properties.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building4(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Applies the building effect to the specified player.
+      *
+      * <p>The method counts the current number of pairs of identical inventors
+      * and grants 3 food for each pair obtained since the last stored value.
+      *
+      * @param player The player who owns the building.
+      * @throws IllegalArgumentException Thrown if the specified player does not own this card.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         HashMap<Integer,Integer> map = new HashMap<>();
+         for(int i=0;i<10;i++)
+         {
+             map.put(i,0);
+         }
+         for(Inventor inv : player.getInventors())
+         {
+             map.merge(inv.getIcon(),1,Integer::sum);
+         }
+         int temp=0;
+         for(Integer i : map.values())
+         {
+             temp+=(i/2);
+         }
+         if(temp<= numPair)
+         {
+             return;
+         }
+         player.addFood(FOOD_PER_INVENTOR_PAIR *(temp-numPair));
+         numPair = temp;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-6/sources/source-7.html b/deliverables/Coverage/htmlReport/ns-6/sources/source-7.html new file mode 100644 index 0000000..d2d775c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-6/sources/source-7.html @@ -0,0 +1,183 @@ + + + + + + + + Coverage Report > Building8 + + + + + + +
+ + +

Coverage Summary for Class: Building8 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Building8 + + 100% + + + (1/1) + + + + 100% + + + (4/4) + + + + 100% + + + (4/4) + + + + 100% + + + (11/11) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ 
+ /**
+  * At the end of the game, you gain double the Prestige Points indicated on the Builder cards in your tribe.
+  */
+ public class Building8 extends BuildingCard {
+ 
+     /**
+      * Constructor of the building
+      * @param era The game era of the building.
+      * @param price The price (in food) of the building.
+      * @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
+      */
+     public Building8(int era, int price,int prestigeValue) {
+         super(era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=8;
+     }
+ 
+     /**
+      * Constructor of the building.
+      *
+      * @param idIMG the image identifier of the building.
+      * @param era the game era of the building.
+      * @param price the price in food of the building.
+      * @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
+      */
+     public Building8(String idIMG,int era, int price,int prestigeValue) {
+         super(idIMG,era,price,prestigeValue);
+         effectType= EffectType.FINAL;
+         effectId=8;
+     }
+ 
+     /**
+      * Method to clone the building: it creates an exact copy.
+      * @return The new copy of the building.
+      */
+     @Override
+     public BuildingCard clone() {
+         return new Building8(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
+     }
+ 
+     /**
+      * Applies the building effect by granting additional Prestige Points equal to
+      * the Prestige Value of each Builder card owned by the player.
+      *
+      * <p>This effectively doubles the contribution of Builder cards to the final score.
+      *
+      * @param player The player who owns the building.
+      * @throws IllegalArgumentException Thrown if the specified player does not own this building.
+      */
+     @Override
+     public void applyEffect(Player player) throws IllegalArgumentException {
+         if(!player.getBuildingCards().contains(this))
+             throw new IllegalArgumentException();
+         for (Builder builder : player.getBuilders()) {
+             player.addPrestige(builder.getPrestigeValue());
+         }
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index.html b/deliverables/Coverage/htmlReport/ns-7/index.html new file mode 100644 index 0000000..e3bb539 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..5169b9b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..4a168d0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..aab603b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..75d3d34 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE.html new file mode 100644 index 0000000..c4b4344 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..de9ad3d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..6393541 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..31a4e82 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..b798557 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,224 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards

+ + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards + + 100% + + + (4/4) + + + + 100% + + + (15/15) + + + + 100% + + + (29/29) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-7/sources/source-1.html new file mode 100644 index 0000000..1f5cb98 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/sources/source-1.html @@ -0,0 +1,213 @@ + + + + + + + + Coverage Report > Character + + + + + + +
+ + +

Coverage Summary for Class: Character (it.polimi.ingsw.gc14.Model.Cards.TribeCards)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Character + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Abstract base class for all character cards.
+  *
+  * <p>A Character is a {@link TribeCard} that is not an event card and is associated
+  * with a specific {@link CharacterType}.
+  */
+ public abstract class  Character extends TribeCard implements Cloneable {
+ 
+     /**
+      * The specific type of this character card.
+      */
+     private CharacterType type;
+ 
+     /**
+      * Returns the type of this character card.
+      *
+      * @return the type of this character card.
+      */
+     public CharacterType getType() {
+         return type;
+     }
+ 
+     /**
+      * Creates a character card with the specified era and character type.
+      *
+      * @param Era the era of the character card.
+      * @param type the type of the character card.
+      */
+     public Character(int Era, CharacterType type){
+         super(Era,false );
+         this.type = type;
+     }
+ 
+     /**
+      * Creates a character card with the specified image id, era and character type.
+      *
+      * @param idIMG the image identifier of the character card.
+      * @param Era the era of the character card.
+      * @param type the type of the character card.
+      */
+     public Character(String idIMG,int Era, CharacterType type){
+         super(idIMG,Era,false );
+         this.type = type;
+     }
+ 
+ 
+     /**
+      * Creates a character card with the specified era, character type,
+      * and minimum number of players.
+      *
+      * @param Era the era of the character card.
+      * @param type the type of the character card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Character(int Era, CharacterType type,int nMin){
+         super(Era,false ,nMin);
+         this.type = type;
+     }
+ 
+     /**
+      * Creates a character card with the specified image id, era, character type,
+      * and minimum number of players.
+      *
+      * @param idIMG the image identifier of the character card.
+      * @param Era the era of the character card.
+      * @param type the type of the character card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Character(String idIMG,int Era, CharacterType type,int nMin){
+         super(idIMG,Era,false ,nMin);
+         this.type = type;
+     }
+ 
+     /**
+      * Returns a string representation of this {@code Character}. This specific variation is used in the {@code Game}'s
+      * toString to provide a more detailed version.
+      * <p>Includes:
+      * <li>{@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType Type}
+      * </p>
+      * @return {@code String} - a string representation of this {@code Character}.
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard()
+     {
+         return super.toStringBoard()+" "+getType().toString()+" ";
+     }
+ 
+     /**
+      * Creates and returns a copy of this character card.
+      *
+      * @return a clone of this character card.
+      */
+     @Override
+     public abstract Character clone();
+ 
+     /**
+      * Inserts this character card into the appropriate collection of the specified player.
+      *
+      * @param player the player who receives the character card.
+      */
+     public abstract void insert(Player player);
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-7/sources/source-2.html new file mode 100644 index 0000000..ab54bf4 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/sources/source-2.html @@ -0,0 +1,141 @@ + + + + + + + + Coverage Report > CharacterType + + + + + + +
+ + +

Coverage Summary for Class: CharacterType (it.polimi.ingsw.gc14.Model.Cards.TribeCards)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
CharacterType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards;
+ 
+  /**
+  * Represents the different types of character cards available in the game.
+  */
+ public enum CharacterType {
+ 
+      /**
+       * Character card representing an Inventor.
+       */
+     INVENTOR,
+ 
+      /**
+       * Character card representing a Builder.
+       */
+      BUILDER,
+ 
+      /**
+       * Character card representing a Gatherer.
+       */
+      GATHERER,
+ 
+      /**
+       * Character card representing an Artist.
+       */
+      ARTIST,
+ 
+      /**
+       * Character card representing a Shaman.
+       */
+      SHAMAN,
+ 
+      /**
+       * Character card representing a Hunter.
+       */
+      HUNTER
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-7/sources/source-3.html new file mode 100644 index 0000000..c75151e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/sources/source-3.html @@ -0,0 +1,196 @@ + + + + + + + + Coverage Report > EventCard + + + + + + +
+ + +

Coverage Summary for Class: EventCard (it.polimi.ingsw.gc14.Model.Cards.TribeCards)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
EventCard + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ import java.util.ArrayList;
+ 
+ /**
+  * Abstract base class for all event cards.
+  * An EventCard is a {@link TribeCard} marked as an event card and associated
+  * with a specific {@link EventType}.
+  */
+ public abstract class EventCard extends TribeCard {
+ 
+     /**
+      * The specific type of this event card.
+      */
+     private EventType type;
+ 
+     /**
+      * Returns the type of this event card.
+      *
+      * @return the type of this event card.
+      */
+     public EventType getType() { return type; }
+ 
+     /**
+      * Creates an event card with the specified era and event type.
+      *
+      * @param era the era of the event card.
+      * @param type the type of the event card.
+      */
+     public EventCard(int era, EventType type) {
+         super(era, true);
+         this.type = type;
+     }
+ 
+     /**
+      * Creates an event card with the specified image id, era and event type.
+      *
+      * @param idIMG the image identifier of the event card.
+      * @param era the era of the event card.
+      * @param type the type of the event card.
+      */
+     public EventCard(String idIMG, int era, EventType type) {
+         super(idIMG, era, true);
+         this.type = type;
+     }
+ 
+     /**
+      * Creates and returns a copy of this event card.
+      *
+      * @return a clone of this event card.
+      */
+     @Override
+     public abstract TribeCard clone();
+ 
+     /**
+      * Returns the string representation of this event card.
+      * The returned string includes the string representation of the superclass
+      * and the string representation of the event type.
+      *
+      * @return the string representation of this event card.
+      */
+     @Override
+     public String toString() {
+         return super.toString() + " " + type.toString();
+     }
+ 
+     /**
+      * Prints a string representation of this {@code EventCard}. This specific variation is used in the {@code Game}'s
+      * toString to print a more detailed version.
+      * <p>Includes:
+      * <li>{@link #type Type}
+      * </p>
+      * @return {@code String} - a string representation of this {@code EventCard}.
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard() + " " + type.toString();
+     }
+ 
+     /**
+      * Activates the effect of this event card on the specified list of players.
+      *
+      * @param playerList the list of players affected by the event.
+      */
+     public abstract void activateEvent (ArrayList <Player> playerList);
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-7/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-7/sources/source-4.html new file mode 100644 index 0000000..7a3c463 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-7/sources/source-4.html @@ -0,0 +1,131 @@ + + + + + + + + Coverage Report > EventType + + + + + + +
+ + +

Coverage Summary for Class: EventType (it.polimi.ingsw.gc14.Model.Cards.TribeCards)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
EventType + + 100% + + + (1/1) + + + + 100% + + + (2/2) + + + + 100% + + + (5/5) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards;
+ 
+  /**
+  * Represents the different types of event cards available in the game.
+  */
+ public enum EventType {
+ 
+      /**
+       * Event card representing Sustenance.
+       */
+      SUSTENANCE,
+ 
+      /**
+       * Event card representing the Shamanic Ritual.
+       */
+      SHAMANIC_RITUAL,
+ 
+      /**
+       * Event card representing Cave Paintings.
+       */
+      CAVE_PAINTINGS,
+ 
+      /**
+       * Event card representing the Hunt.
+       */
+      HUNT
+  }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index.html b/deliverables/Coverage/htmlReport/ns-8/index.html new file mode 100644 index 0000000..a5185e2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..f2a7d34 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..af20e92 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..136cc9a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..23d35e6 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE.html new file mode 100644 index 0000000..0dbc117 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..e726993 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..2ecbc5e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..66ebcdc --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..51b908a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,321 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters + + 100% + + + (6/6) + + + + 100% + + + (49/49) + + + + 100% + + + (40/40) + + + + 100% + + + (108/108) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + + 100% + + + (14/14) + +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-1.html new file mode 100644 index 0000000..00dc0cc --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-1.html @@ -0,0 +1,182 @@ + + + + + + + + Coverage Report > Artist + + + + + + +
+ + +

Coverage Summary for Class: Artist (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Artist + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents an Artist character card.
+  *
+  * <p>An Artist is a specific type of {@link Character} initialized with
+  * {@link CharacterType#ARTIST}.
+  */
+ public class Artist extends Character {
+ 
+     /**
+      * Creates an Artist character card with the specified era.
+      *
+      * @param Era the era of the Artist card.
+      */
+     public Artist(int Era) {
+         super(Era, CharacterType.ARTIST);
+     }
+ 
+     /**
+      * Creates an Artist character card with the specified Era and minimum number of players required to play it.
+      *
+      * @param Era the era of the Artist card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Artist(int Era,int nMin) {
+         super(Era, CharacterType.ARTIST,nMin);
+     }
+ 
+     /**
+      * Creates an Artist character card with the specified image id and era.
+      *
+      * @param idIMG the image identifier of the Artist card.
+      * @param Era the era of the Artist card.
+      */
+     public Artist(String idIMG,int Era) {
+         super(idIMG,Era, CharacterType.ARTIST);
+     }
+ 
+     /**
+      * Creates an Artist character card with the specified image id, era and
+      * minimum number of players required to play it.
+      *
+      * @param idIMG the image identifier of the Artist card.
+      * @param Era the era of the Artist card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Artist(String idIMG,int Era,int nMin) {
+         super(idIMG,Era, CharacterType.ARTIST,nMin);
+     }
+ 
+     /**
+      * Creates and returns a copy of this Artist card.
+      *
+      * @return a clone of this Artist card.
+      */
+     @Override
+     public Character clone() {
+         return new Artist(getIdIMG(),getEra(), getNMin());
+     }
+ 
+     /**
+      * Inserts this Artist card into the specified player's Artist collection
+      * and applies any building effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player) {
+         player.getArtists().add(this);
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-2.html new file mode 100644 index 0000000..150af73 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-2.html @@ -0,0 +1,298 @@ + + + + + + + + Coverage Report > Builder + + + + + + +
+ + +

Coverage Summary for Class: Builder (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Builder + + 100% + + + (1/1) + + + + 100% + + + (10/10) + + + + 100% + + + (16/16) + + + + 100% + + + (35/35) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents a Builder character card.
+  *
+  * <p>A Builder is a specific type of {@link Character} that provides
+  * a reduction value when buying building cards.
+  */
+ public class Builder extends Character {
+ 
+     /**
+      * The reduction value provided by this Builder card.
+      */
+     private int reductionValue;
+ 
+     /**
+      * The prestige value provided by this Builder card.
+      */
+     private int prestigeValue;
+ 
+     /**
+      * Returns the reduction value of this Builder card.
+      *
+      * @return the reduction value of this Builder card.
+      */
+     public int getReductionValue() {
+         return reductionValue;
+     }
+ 
+     /**
+      * Returns the prestige value of this Builder card.
+      *
+      * @return the prestige value of this Builder card.
+      */
+     public int getPrestigeValue() {
+         return prestigeValue;
+     }
+ 
+     /**
+      * Creates a Builder character card with the specified era, reduction value,
+      * and prestige value.
+      *
+      * @param Era the era of the Builder card.
+      * @param reductionValue the reduction value of the Builder card.
+      * @param prestigeValue the prestige value of the Builder card.
+      * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
+      */
+     public Builder(int Era, int reductionValue, int prestigeValue)  throws IllegalArgumentException {
+         super(Era,CharacterType.BUILDER);
+         if(reductionValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.reductionValue = reductionValue;
+ 
+         if(prestigeValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.prestigeValue = prestigeValue;
+     }
+ 
+     /**
+      * Creates a Builder character card with the specified era, reduction value,
+      * prestige value, and minimum number of players.
+      *
+      * @param Era the era of the Builder card.
+      * @param reductionValue the reduction value of the Builder card.
+      * @param prestigeValue the prestige value of the Builder card.
+      * @param nMin the minimum number of players required for the card.
+      * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
+      */
+     public Builder(int Era, int reductionValue, int prestigeValue,int nMin)  throws IllegalArgumentException {
+         super(Era,CharacterType.BUILDER,nMin);
+         if(reductionValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.reductionValue = reductionValue;
+ 
+         if(prestigeValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.prestigeValue = prestigeValue;
+     }
+ 
+     /**
+      * Creates a Builder character card with the specified era, reduction value,
+      * and prestige value.
+      *
+      * @param idIMG the image identifier of the Builder card.
+      * @param Era the era of the Builder card.
+      * @param reductionValue the reduction value of the Builder card.
+      * @param prestigeValue the prestige value of the Builder card.
+      * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
+      */
+     public Builder(String idIMG,int Era, int reductionValue, int prestigeValue)  throws IllegalArgumentException {
+         super(idIMG,Era,CharacterType.BUILDER);
+         if(reductionValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.reductionValue = reductionValue;
+ 
+         if(prestigeValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.prestigeValue = prestigeValue;
+     }
+ 
+     /**
+      * Creates a Builder character card with the specified era, reduction value,
+      * prestige value, and minimum number of players.
+      *
+      * @param idIMG the image identifier of the Builder card.
+      * @param Era the era of the Builder card.
+      * @param reductionValue the reduction value of the Builder card.
+      * @param prestigeValue the prestige value of the Builder card.
+      * @param nMin the minimum number of players required for the card.
+      * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
+      */
+     public Builder(String idIMG,int Era, int reductionValue, int prestigeValue,int nMin)  throws IllegalArgumentException {
+         super(idIMG,Era,CharacterType.BUILDER,nMin);
+         if(reductionValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.reductionValue = reductionValue;
+ 
+         if(prestigeValue < 0)  {
+             throw new IllegalArgumentException();
+         }
+         this.prestigeValue = prestigeValue;
+     }
+ 
+     /**
+      * Returns the string representation of this Builder card.
+      *
+      * @return the string representation of this Builder card.
+      */
+     @Override
+     public String toString()  {
+         return super.toStringBoard() + "\uD83D\uDD28:" + String.valueOf(reductionValue) + " \uD83C\uDFC5:" + String.valueOf(prestigeValue);
+     }
+ 
+     /**
+      * Returns a detailed string representation of this {@code Builder} card,
+      * including its reduction value and prestige value.
+      *
+      * @return a detailed string representation of this {@code Builder} card.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard()
+     {
+         return super.toStringBoard()+"\uD83D\uDD28:" + String.valueOf(reductionValue) + " \uD83C\uDFC5:" + String.valueOf(prestigeValue);
+     }
+ 
+ 
+     /**
+      * Creates and returns a copy of this Builder card.
+      *
+      * @return a clone of this Builder card.
+      */
+     @Override
+     public Character clone() {
+         return new Builder(getIdIMG(),getEra(),getReductionValue(), getPrestigeValue(), getNMin());
+     }
+ 
+     /**
+      * Inserts this Builder card into the specified player's Builder collection
+      * and applies any building effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player) {
+         player.getBuilders().add(this);
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-3.html new file mode 100644 index 0000000..898de06 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-3.html @@ -0,0 +1,181 @@ + + + + + + + + Coverage Report > Gatherer + + + + + + +
+ + +

Coverage Summary for Class: Gatherer (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Gatherer + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents a Gatherer character card.
+  *
+  * <p>A Gatherer is a specific type of {@link Character} initialized with
+  * {@link CharacterType#GATHERER}.
+  */
+ public class Gatherer extends Character {
+ 
+     /**
+      * Creates a Gatherer character card with the specified era.
+      *
+      * @param Era the era of the Gatherer card.
+      */
+     public Gatherer(int Era) {
+         super(Era, CharacterType.GATHERER);
+     }
+ 
+     /**
+      * Creates a Gatherer character card with the specified era and minimum number of players.
+      *
+      * @param Era the era of the Gatherer card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Gatherer(int Era, int nMin) {
+         super(Era, CharacterType.GATHERER,nMin);
+     }
+ 
+     /**
+      * Creates a Gatherer character card with the specified image id and era.
+      *
+      * @param idIMG the image identifier of the Gatherer card.
+      * @param Era the era of the Gatherer card.
+      */
+     public Gatherer(String idIMG,int Era) {
+         super(idIMG,Era, CharacterType.GATHERER);
+     }
+ 
+     /**
+      * Creates a Gatherer character card with the specified image id, era and
+      * minimum number of players.
+      *
+      * @param idIMG the image identifier of the Gatherer card.
+      * @param Era the era of the Gatherer card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Gatherer(String idIMG,int Era, int nMin) {
+         super(idIMG,Era, CharacterType.GATHERER,nMin);
+     }
+ 
+     /**
+      * Creates and returns a copy of this Gatherer card.
+      *
+      * @return a clone of this Gatherer card.
+      */
+     @Override
+     public Character clone() {
+         return new Gatherer(getIdIMG(),getEra(), getNMin());
+     }
+ 
+     /**
+      * Inserts this Gatherer card into the specified player's Gatherer collection
+      * and applies any building effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player) {
+         player.getGatherers().add(this);
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-4.html new file mode 100644 index 0000000..044caf5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-4.html @@ -0,0 +1,262 @@ + + + + + + + + Coverage Report > Hunter + + + + + + +
+ + +

Coverage Summary for Class: Hunter (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Hunter + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (6/6) + + + + 100% + + + (22/22) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents a Hunter character card.
+  *
+  * <p>A Hunter is a specific type of {@link Character} initialized with
+  * {@link CharacterType#HUNTER}.
+  */
+ public class Hunter extends Character {
+ 
+     /**
+      * Describes whether the {@code Hunter Icon} is present or not. Whenever an
+      * {@code Hunter} with an {@code Hunter Icon} is added to the tribe, 1 {@code Food token} is awarded for each Hunter in the tribe
+      * (with or without an icon).
+      */
+     private boolean icon;
+ 
+     /**
+      * Returns whether this Hunter card has the icon.
+      *
+      * @return {@code true} if this Hunter card has the icon, {@code false} otherwise.
+      */
+     public boolean getIcon() {
+         return icon;
+     }
+ 
+     /**
+      * Creates a Hunter character card with the specified era and icon value.
+      *
+      * @param Era the era of the Hunter card.
+      * @param icon the icon value of the Hunter card.
+      */
+     public Hunter(int Era, boolean icon) {
+         super(Era, CharacterType.HUNTER);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Hunter character card with the specified era, icon value,
+      * and minimum number of players.
+      *
+      * @param Era the era of the Hunter card.
+      * @param icon the icon value of the Hunter card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Hunter(int Era, boolean icon, int nMin) {
+         super(Era, CharacterType.HUNTER,nMin);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Hunter character card with the specified image id, era and icon value.
+      *
+      * @param idIMG the image identifier of the Hunter card.
+      * @param Era the era of the Hunter card.
+      * @param icon the icon value of the Hunter card.
+      */
+     public Hunter(String idIMG,int Era, boolean icon) {
+         super(idIMG,Era, CharacterType.HUNTER);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Hunter character card with the specified image id, era, icon value,
+      * and minimum number of players.
+      *
+      * @param idIMG the image identifier of the Hunter card.
+      * @param Era the era of the Hunter card.
+      * @param icon the icon value of the Hunter card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Hunter(String idIMG,int Era, boolean icon, int nMin) {
+         super(idIMG,Era, CharacterType.HUNTER,nMin);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Returns the string representation of this Hunter card.
+      *
+      * @return the string representation of this Hunter card.
+      */
+     @Override
+     public String toString() {
+         String toPrint = super.toString();
+         if(this.icon){
+             toPrint += "\uD83C\uDF56";
+         }
+         return toPrint;
+     }
+ 
+     /**
+      * Returns a detailed string representation of this {@code TribeCard}.
+      * This specific variation is used in the {@code Game}'s
+      * toString to provide a more detailed version.
+      *
+      * <p>Potentially includes:
+      * <li>{@link #icon Icon}
+      * </p>
+      *
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         String toPrint = super.toStringBoard();
+         if(this.icon){
+             toPrint += "\uD83C\uDF56";
+         }
+         return toPrint;
+     }
+ 
+     /**
+      * Creates and returns a copy of this Hunter card.
+      *
+      * @return a clone of this Hunter card.
+      */
+     @Override
+     public Character clone() {
+         return new Hunter(getIdIMG(),getEra(), getIcon(), getNMin());
+     }
+ 
+     /**
+      * Inserts this Hunter card into the specified player's Hunter collection.
+      *
+      * <p>If this card has the Hunter icon, the player gains 1 food for each
+      * Hunter currently in their tribe. The method also applies any building
+      * effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player) {
+         player.getHunters().add(this);
+         if(this.getIcon()){
+             player.addFood(player.getHunters().size());
+         }
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-5.html new file mode 100644 index 0000000..4abb9db --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-5.html @@ -0,0 +1,258 @@ + + + + + + + + Coverage Report > Inventor + + + + + + +
+ + +

Coverage Summary for Class: Inventor (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Inventor + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (18/18) + + + + 100% + + + (23/23) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents an Inventor character card.
+  *
+  * <p>An Inventor is a specific type of {@link Character} initialized with
+  * {@link CharacterType#INVENTOR}.
+  */
+ public class Inventor extends Character {
+     /**
+      * The {@code Icons}'s ID. There are a total of 10 different Icons.
+      */
+     private int icon;
+ 
+     /**
+      * Returns the icon value of this Inventor card.
+      *
+      * @return the icon value of this Inventor card.
+      */
+     public int getIcon() {
+         return icon;
+     }
+ 
+     /**
+      * Creates an Inventor character card with the specified era and icon value.
+      *
+      * @param Era the era of the Inventor card.
+      * @param icon the icon value of the Inventor card.
+      * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
+      */
+     public Inventor(int Era,int icon) throws IllegalArgumentException {
+         super(Era, CharacterType.INVENTOR);
+         if(icon<0 || icon>9)
+             throw new IllegalArgumentException();
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates an Inventor character card with the specified era, icon value,
+      * and minimum number of players.
+      *
+      * @param Era the era of the Inventor card.
+      * @param icon the icon value of the Inventor card.
+      * @param nMin the minimum number of players required for the card.
+      * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
+      */
+     public Inventor(int Era,int icon,int nMin) throws IllegalArgumentException {
+         super(Era, CharacterType.INVENTOR,nMin);
+         if(icon<0 || icon>9)
+             throw new IllegalArgumentException();
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates an Inventor character card with the specified image id, era and icon value.
+      *
+      * @param idIMG the image identifier of the Inventor card.
+      * @param Era the era of the Inventor card.
+      * @param icon the icon value of the Inventor card.
+      * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
+      */
+     public Inventor(String idIMG,int Era,int icon) throws IllegalArgumentException {
+         super(idIMG,Era, CharacterType.INVENTOR);
+         if(icon<0 || icon>9)
+             throw new IllegalArgumentException();
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates an Inventor character card with the specified image id, era, icon value,
+      * and minimum number of players.
+      *
+      * @param idIMG the image identifier of the Inventor card.
+      * @param Era the era of the Inventor card.
+      * @param icon the icon value of the Inventor card.
+      * @param nMin the minimum number of players required for the card.
+      * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
+      */
+     public Inventor(String idIMG,int Era,int icon,int nMin) throws IllegalArgumentException {
+         super(idIMG,Era, CharacterType.INVENTOR,nMin);
+         if(icon<0 || icon>9)
+             throw new IllegalArgumentException();
+         this.icon = icon;
+     }
+ 
+     /**
+      * Returns the string representation of this Inventor card.
+      *
+      * @return the string representation of this Inventor card.
+      */
+     @Override
+     public String toString() {
+         return  super.toString() + "ID:" + String.valueOf(icon);
+     }
+ 
+     /**
+      * Returns a detailed string representation of this {@code TribeCard}.
+      * This specific variation is used in the {@code Game}'s toString
+      * to provide a more detailed version.
+      *
+      * <p>Includes:
+      * <li>{@link #icon Icons's ID}
+      * </p>
+      *
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return  super.toStringBoard() + "ID:" + String.valueOf(icon);
+     }
+ 
+     /**
+      * Creates and returns a copy of this Inventor card.
+      *
+      * @return a clone of this Inventor card.
+      */
+     @Override
+     public Character clone()  {
+         return new Inventor(getIdIMG(),getEra(),icon, getNMin());
+     }
+ 
+     /**
+      * Inserts this Inventor card into the specified player's Inventor collection.
+      *
+      * <p>The method also applies the building effects related to inventor pairs
+      * and any building effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player) {
+         player.getInventors().add(this);
+         player.getBuildingCards().stream().filter(b -> b.getEffectId() == 4).forEach(b4 -> b4.applyEffect(player));
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-8/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-8/sources/source-6.html new file mode 100644 index 0000000..76a816d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-8/sources/source-6.html @@ -0,0 +1,234 @@ + + + + + + + + Coverage Report > Shaman + + + + + + +
+ + +

Coverage Summary for Class: Shaman (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
Shaman + + 100% + + + (1/1) + + + + 100% + + + (9/9) + + + + 100% + + + (14/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ /**
+  * Represents a Shaman character card.
+  *
+  * <p>A Shaman is a specific type of {@link Character} initialized with
+  * {@link CharacterType#SHAMAN}.
+  */
+ public class Shaman extends Character {
+     /**
+      * The number of star {@code Icons} the card possesses.
+      * During the {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual Shamanic Ritual Event}, having the
+      * majority of these icons provides Prestige Points;
+      * having the minority, on the other hand, results in
+      * losing Prestige Points.
+      */
+     private int icon;
+ 
+     /**
+      * Returns the icon value of this Shaman card.
+      *
+      * @return the icon value of this Shaman card.
+      */
+     public int getIcon() {
+         return icon;
+     }
+ 
+     /**
+      * Creates a Shaman character card with the specified era and icon value.
+      *
+      * @param Era the era of the Shaman card.
+      * @param icon the icon value of the Shaman card.
+      */
+     public Shaman(int Era, int icon) {
+         super(Era, CharacterType.SHAMAN);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Shaman character card with the specified era, icon value,
+      * and minimum number of players.
+      *
+      * @param Era the era of the Shaman card.
+      * @param icon the icon value of the Shaman card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Shaman(int Era, int icon, int nMin) {
+         super(Era, CharacterType.SHAMAN,nMin);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Shaman character card with the specified image id, era and icon value.
+      *
+      * @param idIMG the image identifier of the Shaman card.
+      * @param Era the era of the Shaman card.
+      * @param icon the icon value of the Shaman card.
+      */
+     public Shaman(String idIMG,int Era, int icon) {
+         super(idIMG,Era, CharacterType.SHAMAN);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Creates a Shaman character card with the specified image id, era, icon value,
+      * and minimum number of players.
+      *
+      * @param idIMG the image identifier of the Shaman card.
+      * @param Era the era of the Shaman card.
+      * @param icon the icon value of the Shaman card.
+      * @param nMin the minimum number of players required for the card.
+      */
+     public Shaman(String idIMG,int Era, int icon, int nMin) {
+         super(idIMG,Era, CharacterType.SHAMAN,nMin);
+         this.icon = icon;
+     }
+ 
+     /**
+      * Returns the string representation of this Shaman card.
+      *
+      * @return the string representation of this Shaman card.
+      */
+     @Override
+     public String toString() {
+         return super.toString() + "🌟:" + icon;
+     }
+ 
+     /**
+      * Returns a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
+      * toString to provide a more detailed version.
+      * <p>Includes:
+      * <li>{@link #icon Number of stars}
+      * </p>
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard() + "🌟:" + icon;
+     }
+ 
+     /**
+      * Creates and returns a copy of this Shaman card.
+      *
+      * @return a clone of this Shaman card.
+      */
+     @Override
+     public Character clone()  {
+         return new  Shaman(getIdIMG(),getEra(), getIcon(), getNMin());
+     }
+ 
+     /**
+      * Inserts this Shaman card into the specified player's Shaman collection
+      * and applies any building effects triggered by character set completion.
+      *
+      * @param player the player who receives the card.
+      */
+     @Override
+     public void insert(Player player)
+     {
+         player.getShamans().add(this);
+         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index.html b/deliverables/Coverage/htmlReport/ns-9/index.html new file mode 100644 index 0000000..91e998b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..d833c20 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..4de6dd4 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..3677cc4 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..255e3c8 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE.html new file mode 100644 index 0000000..654a30e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..29f4faa --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..016eb82 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..9f9b6a7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..f6a32b9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,272 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events + + 100% + + + (4/4) + + + + 100% + + + (24/24) + + + + 100% + + + (48/48) + + + + 100% + + + (91/91) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-9/sources/source-1.html new file mode 100644 index 0000000..d60c76f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/sources/source-1.html @@ -0,0 +1,247 @@ + + + + + + + + Coverage Report > CavePaintings + + + + + + +
+ + +

Coverage Summary for Class: CavePaintings (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
CavePaintings + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (8/8) + + + + 100% + + + (21/21) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import java.util.ArrayList;
+ 
+ /**
+  * Represents a Cave Paintings event card.
+  *
+  * <p>This class defines the specific behavior of the Cave Paintings event.
+  */
+ public class CavePaintings extends EventCard {
+ 
+     /**
+      * The minimum number of Artist cards required to avoid the prestige penalty.
+      * Also, the bottom number on the card.
+      */
+     private int nLower;
+ 
+     /**
+      * The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
+      */
+     private int nPrestigeRem; // NPrestigeLower
+ 
+     /**
+      * The Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
+      */
+     private int nPrestigeMul; // NPrestigeUpper
+ 
+     /**
+      * Creates a CavePaintings event card with the specified era and effect parameters.
+      *
+      * @param Era the era of the event card.
+      * @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
+      * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
+      * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
+      */
+     public CavePaintings(int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
+         super(Era, EventType.CAVE_PAINTINGS);
+         this.nLower = nLower;
+         this.nPrestigeRem = nPrestigeRem;
+         this.nPrestigeMul = nPrestigeMul;
+     }
+ 
+     /**
+      * Creates a CavePaintings event card with the specified image id, era and effect parameters.
+      *
+      * @param idIMG the image identifier of the CavePaintings event card.
+      * @param Era the era of the event card.
+      * @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
+      * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
+      * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
+      */
+     public CavePaintings(String idIMG,int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
+         super(idIMG,Era, EventType.CAVE_PAINTINGS);
+         this.nLower = nLower;
+         this.nPrestigeRem = nPrestigeRem;
+         this.nPrestigeMul = nPrestigeMul;
+     }
+ 
+     /**
+      * Activates the CavePaintings event for the specified list of players.
+      * For each player, the number of Artist cards is computed together with the number
+      * of owned building cards having effect id equal to 9.
+      * The player gains Food equal to the number of such buildings multiplied by the number of Artist cards.
+      * If the player has fewer Artist cards than {@code nLower}, the player loses {@code nPrestigeRem} Prestige.
+      * Otherwise, the player gains Prestige equal to {@code nPrestigeMul} multiplied by the number of Artist cards.
+      *
+      * @param playerList the list of players affected by the event.
+      */
+     @Override
+     public void activateEvent (ArrayList <Player> playerList){
+         for (Player player : playerList){
+             int nArtists = player.getNType(CharacterType.ARTIST);
+             int nBuildings = 0;
+             ArrayList<BuildingCard> buildingCards = player.getBuildingCards();
+ 
+             for(BuildingCard card : buildingCards){
+                 if(card.getEffectId() == 9){
+                     nBuildings++;
+                 }
+             }
+             player.addFood(nBuildings * nArtists);
+             if (nArtists < nLower){
+                 player.removePrestige(nPrestigeRem);
+             }
+             else{
+                 player.addPrestige(nPrestigeMul * nArtists);
+             }
+         }
+     }
+ 
+     /**
+      * Creates and returns a copy of this CavePaintings event card.
+      *
+      * @return a clone of this CavePaintings event card.
+      */
+     @Override
+     public EventCard clone()
+     {
+         return new CavePaintings(getIdIMG(),getEra(), nLower, nPrestigeRem, nPrestigeMul) ;
+     }
+ 
+     /**
+      * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
+      * toString to print a more detailed version.
+      * <p>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code nLower} is needed),
+      * however it's a parameter on the cards' design.
+      * </p>
+      * <p>Includes:
+      * <li>{@link #nLower}
+      * <li>{@code NUpper}
+      * <li>{@link #nPrestigeRem}
+      * <li>{@link #nPrestigeMul}
+      * </p>
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-9/sources/source-2.html new file mode 100644 index 0000000..3289093 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/sources/source-2.html @@ -0,0 +1,219 @@ + + + + + + + + Coverage Report > Hunt + + + + + + +
+ + +

Coverage Summary for Class: Hunt (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Hunt + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (6/6) + + + + 100% + + + (18/18) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import java.util.ArrayList;
+ 
+ /**
+  * When activated, gives Food and Prestige Points to every player.
+  *
+  * @see EventCard
+  */
+ public class Hunt extends EventCard {
+     /** Base food units granted per Hunter. Always 1; increased by Building 7. */
+     private static final int BASE_FOOD_PER_HUNTER = 1;
+ 
+     /** Prestige Points multiplier used during the event. */
+     private int prestigeMultiplier;
+ 
+     int getPrestigeMultiplier() { return prestigeMultiplier; }
+ 
+     /**
+      * Creates a new Hunt event card.
+      *
+      * @param Era                      the era of the card
+      * @param prestigeMultiplier    prestige points multiplicator used during the event
+      */
+     public Hunt(int Era, int prestigeMultiplier) {
+         super(Era, EventType.HUNT);
+         this.prestigeMultiplier = prestigeMultiplier;
+     }
+ 
+     /**
+      * Creates a new Hunt event card.
+      *
+      * @param idIMG the image identifier of the Hunt event card.
+      * @param Era the era of the card.
+      * @param prestigeMultiplier the prestige points multiplier used during the event.
+      */
+     public Hunt(String idIMG, int Era, int prestigeMultiplier) {
+         super(idIMG, Era, EventType.HUNT);
+         this.prestigeMultiplier = prestigeMultiplier;
+     }
+ 
+     /**
+      * Activates the event card "Hunt".
+      * Each player gains Food and Prestige Points for each Hunter in their tribe,
+      * multiplied by the respective multipliers (base food per hunter is 1).
+      * Buildings influence:
+      *      Building 7: adds 1 to both the food and prestige multiplier for each copy owned.
+      *
+      * @param playerList the list of all players in the game.
+      */
+     @Override
+     public void activateEvent (ArrayList <Player> playerList){
+         for (Player player : playerList) {
+             int tmpFoodMultiplier = BASE_FOOD_PER_HUNTER;
+             int tmpPrestigeMultiplier = prestigeMultiplier;
+ 
+             ArrayList <BuildingCard> buildingList = player.getBuildingCards();
+             int hunterCounter=player.getNType(CharacterType.HUNTER);
+ 
+             for (BuildingCard buildingCard : buildingList) {
+                 if (buildingCard.getEffectId() == 7) {
+                     tmpFoodMultiplier++;
+                     tmpPrestigeMultiplier++;
+                 }
+             }
+ 
+             player.addFood(tmpFoodMultiplier * hunterCounter);
+             player.addPrestige(tmpPrestigeMultiplier * hunterCounter);
+         }
+     }
+ 
+     /**
+      * Creates and returns a copy of this Hunt card.
+      *
+      * @return a new Hunt card with the same era and prestige multiplier
+      */
+     @Override
+     public EventCard clone() {
+         return new Hunt(getIdIMG(),getEra(), prestigeMultiplier);
+     }
+ 
+     /**
+      * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
+      * toString to print a more detailed version.
+      * <p>includes:
+      * <li>{@link #prestigeMultiplier}
+      * </p>
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard()+" 1\uD83C\uDF56+"+prestigeMultiplier+"\uD83C\uDFC5"+"×\uD83C\uDFF9";
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-9/sources/source-3.html new file mode 100644 index 0000000..c44431f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/sources/source-3.html @@ -0,0 +1,256 @@ + + + + + + + + Coverage Report > ShamanicRitual + + + + + + +
+ + +

Coverage Summary for Class: ShamanicRitual (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ShamanicRitual + + 100% + + + (1/1) + + + + 100% + + + (7/7) + + + + 100% + + + (24/24) + + + + 100% + + + (30/30) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * When activated, rewards the player with the most shaman icons and penalizes the one with the fewest.
+  *
+  * @see EventCard
+  */
+ public class ShamanicRitual extends EventCard {
+     /** Bonus shaman icons granted per Building 5 owned during this event. */
+     private static final int BUILDING5_BONUS_ICONS = 3;
+ 
+     /** Prestige points awarded to the player with the most shaman icons. */
+     private int prestigeToAdd;
+ 
+     // TODO
+     int getPrestigeToAdd() { return prestigeToAdd; }
+ 
+     /** Prestige points removed from the player with the fewest shaman icons. */
+     private int prestigeToRemove;
+ 
+     // TODO
+     int getPrestigeToRemove() { return prestigeToRemove; }
+ 
+     /**
+      * Creates a new ShamanicRitual event card.
+      *
+      * @param Era              the era of the card
+      * @param prestigeToAdd    prestige points awarded to the player with the most icons
+      * @param prestigeToRemove prestige points removed from the player with the fewest icons
+      */
+     public ShamanicRitual(int Era, int prestigeToAdd, int prestigeToRemove) {
+         super(Era, EventType.SHAMANIC_RITUAL);
+         this.prestigeToAdd = prestigeToAdd;
+         this.prestigeToRemove = prestigeToRemove;
+ 
+     }
+ 
+     /**
+      * Creates a new ShamanicRitual event card.
+      *
+      * @param idIMG the image identifier of the ShamanicRitual event card.
+      * @param Era the era of the card.
+      * @param prestigeToAdd prestige points awarded to the player with the most icons.
+      * @param prestigeToRemove prestige points removed from the player with the fewest icons.
+      */
+     public ShamanicRitual(String idIMG,int Era, int prestigeToAdd, int prestigeToRemove) {
+         super(idIMG,Era, EventType.SHAMANIC_RITUAL);
+         this.prestigeToAdd = prestigeToAdd;
+         this.prestigeToRemove = prestigeToRemove;
+ 
+     }
+ 
+     /**
+      * Activates the event card "Shamanic Ritual".
+      * The player with the most icons gains the Prestige Points indicated.
+      * The player with the fewest icons loses the Prestige Points indicated.
+      * In case of a tie, all players gain or lose the Prestige Points indicated.
+      * If all players have the same amount of icons, they all gain and lose Prestige Points.
+      * Buildings influence:
+      *      Building 2: if you have the lowest number of icons, you don't lose Prestige Points
+      *      Building 5: during the Shamanic Ritual, you gain 3 icons
+      *      Building 6: if you have more icons than any other player, you gain double of Prestige Points
+      *
+      * @param playerList contains all the players in the game
+      */
+     @Override
+     public void activateEvent (ArrayList <Player> playerList){
+         Map<Player, Integer> playerMap = new HashMap<>();
+         int tmpIcons = 0;
+         int tmpCount = 0;
+ 
+         for (Player player : playerList) {
+             tmpIcons = player.getShamans().stream().mapToInt(sh -> sh.getIcon()).sum();
+             tmpCount = (int) player.getBuildingCards().stream().filter(b -> b.getEffectId() == 5).count();
+             if (tmpCount >= 1) {
+                 tmpIcons = tmpIcons+(BUILDING5_BONUS_ICONS *tmpCount);
+             }
+             playerMap.put(player, tmpIcons);
+         }
+ 
+         int maxIcon = playerMap.values().stream().mapToInt(Integer::intValue).max().orElse(0);
+         int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0);
+ 
+         List<Player> maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).collect(Collectors.toList());
+         List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.toList());
+ 
+ 
+         for (Player player : maxIconsPlayer) {
+             if (player.getBuildingCards().stream().anyMatch(b -> b.getEffectId() == 6) && maxIconsPlayer.size() == 1) {
+                 player.addPrestige(prestigeToAdd * 2);
+             } else {
+                 player.addPrestige(prestigeToAdd);
+             }
+         }
+ 
+         for (Player player : minIconsPlayer) {
+             if (!(player.getBuildingCards().stream().anyMatch(b -> b.getEffectId() == 2))) {
+                 player.removePrestige(prestigeToRemove);
+             }
+         }
+ 
+     }
+ 
+     /**
+      * Creates and returns a copy of this ShamanicRitual card.
+      *
+      * @return a new ShamanicRitual card with the same era and prestige values
+      */
+     @Override
+     public EventCard clone() {
+         return new ShamanicRitual(getIdIMG(),getEra(), prestigeToAdd, prestigeToRemove);
+     }
+ 
+     /**
+      * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
+      * toString to print a more detailed version.
+      * <p>Includes:
+      * <li>{@link #prestigeToAdd}
+      * <li>{@link #prestigeToRemove}
+      * </p>
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard()+" \uD83C\uDF1F>:"+prestigeToAdd+" \uD83C\uDF1F<:"+prestigeToRemove;
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-9/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-9/sources/source-4.html new file mode 100644 index 0000000..792017b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-9/sources/source-4.html @@ -0,0 +1,242 @@ + + + + + + + + Coverage Report > Sustenance + + + + + + +
+ + +

Coverage Summary for Class: Sustenance (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Sustenance + + 100% + + + (1/1) + + + + 100% + + + (6/6) + + + + 100% + + + (10/10) + + + + 100% + + + (22/22) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building1;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import java.util.ArrayList;
+ 
+ /**
+  * Represents a Sustenance event card.
+  *
+  * <p>This class defines the specific behavior of the Sustenance event.
+  */
+ public class Sustenance extends EventCard {
+ 
+     /** Food units covered by each Gatherer during the Sustenance event. */
+     private static final int FOOD_PER_GATHERER = 3;
+ 
+     /**
+      * The prestige penalty multiplier applied for each unpaid Food unit.
+      */
+     private int prestigeDebt;
+ 
+     /**
+      * Returns the prestige penalty multiplier associated with this Sustenance event.
+      *
+      * @return the prestige penalty multiplier associated with this Sustenance event.
+      */
+     public int getPrestigeDebt() {
+         return prestigeDebt;
+     }
+ 
+     /**
+      * Creates a Sustenance event card with the specified era and prestige debt value.
+      *
+      * @param Era the era of the event card.
+      * @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
+      */
+     public Sustenance(int Era, int prestigeDebt) {
+         super(Era, EventType.SUSTENANCE);
+         this.prestigeDebt = prestigeDebt;
+     }
+ 
+     /**
+      * Creates a Sustenance event card with the specified image id, era and prestige debt value.
+      *
+      * @param idIMG the image identifier of the Sustenance event card.
+      * @param Era the era of the event card.
+      * @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
+      */
+     public Sustenance(String idIMG,int Era, int prestigeDebt) {
+         super(idIMG,Era, EventType.SUSTENANCE);
+         this.prestigeDebt = prestigeDebt;
+     }
+ 
+     /**
+      * Activates the Sustenance event for the specified list of players.
+      * For each player, the required Food is computed from the total number of characters,
+      * reduced by the contribution of Gatherers and by any applicable character discounts
+      * granted by owned building cards with effect id equal to 1.
+      * If the resulting Food debt is positive, the player must pay it with available Food.
+      * If the player does not have enough Food, all remaining Food is removed and the player
+      * loses Prestige equal to the unpaid Food debt multiplied by {@code prestigeDebt}.
+      * <b>This event is intended to be executed last among event effects.</b>
+      *
+      * @param playerList the list of players affected by the event.
+      */
+     @Override
+     public void activateEvent (ArrayList <Player> playerList) {
+         for(Player player : playerList){
+             int nChar = player.getTotCharacters();
+             int nGatherers = player.getNType(CharacterType.GATHERER);
+ 
+             int nCharDiscount = 0;
+             for(BuildingCard b : player.getBuildingCards()){
+                 if(b.getEffectId() == 1){
+                     CharacterType c = ((Building1)b).getIcon();
+                     nCharDiscount += player.getNType(c);
+                 }
+             }
+ 
+ 
+             int foodDebt = nChar - (FOOD_PER_GATHERER * nGatherers + nCharDiscount);
+ 
+             if(foodDebt <= 0){
+                 continue;
+             }
+             if(player.getFoodValue() >= foodDebt){
+                 player.removeFood(foodDebt);
+             }
+             else{
+                 foodDebt -= player.getFoodValue();
+                 player.removeFood(player.getFoodValue());               // player.getFoodValue() == 0
+                 player.removePrestige(foodDebt * prestigeDebt);
+             }
+         }
+     }
+ 
+     /**
+      * Creates and returns a copy of this Sustenance event card.
+      *
+      * @return a clone of this Sustenance event card.
+      */
+     @Override
+     public EventCard clone() {
+         return new Sustenance(getIdIMG(),getEra(), prestigeDebt);
+     }
+ 
+     /**
+      * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
+      * toString to print a more detailed version.
+      * <p>Includes:
+      * <li>{@link #prestigeDebt}
+      * </p>
+      * @return {@code String} - a string representation of this {@code TribeCard}.
+      * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
+      * @see it.polimi.ingsw.gc14.Model.Game Game
+      * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
+      */
+     @Override
+     public String toStringBoard() {
+         return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index.html b/deliverables/Coverage/htmlReport/ns-a/index.html new file mode 100644 index 0000000..4116065 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..00cd3e2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..1f7eda8 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..0371489 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..d1e5fa0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE.html new file mode 100644 index 0000000..e81adbf --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..e73b600 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..984d980 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..9ce5e92 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..83c5e20 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,230 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.GamePackage + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.GamePackage

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.GamePackage + + 100% + + + (3/3) + + + + 94.3% + + + (33/35) + + + + 96.9% + + + (31/32) + + + + 88.2% + + + (120/136) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + + 91.7% + + + (11/12) + +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-a/sources/source-1.html new file mode 100644 index 0000000..93a5daf --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/sources/source-1.html @@ -0,0 +1,424 @@ + + + + + + + + Coverage Report > Board + + + + + + +
+ + +

Coverage Summary for Class: Board (it.polimi.ingsw.gc14.Model.GamePackage)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Board + + 100% + + + (1/1) + + + + 100% + + + (16/16) + + + + 96.7% + + + (29/30) + + + + 100% + + + (82/82) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.GamePackage;
+ 
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Sustenance;
+ import it.polimi.ingsw.gc14.Model.DecksCreator;
+ import it.polimi.ingsw.gc14.Model.Slot;
+ 
+ import java.io.Serializable;
+ import java.util.*;
+ import java.util.stream.Collectors;
+ 
+ /**
+  * Board manages all the elements during the game such as decks, upper and lower rows, totems, tiles...
+  */
+ public class Board implements Serializable {
+     /**
+      * slotList contains the ordered list of slots (tiles). The slots changes based on the number of players.
+      * Each slot (tile) has special action as drawing from the upper/lower row or taking food.
+      */
+     private List<Slot> slotList;
+ 
+     /** tribeDeck is the deck from where you draw tribe cards as characters and events. */
+     private Queue<TribeCard> tribeDeck;
+ 
+     /**
+      * The upper row of tribe cards. It contains a total of
+      * {@code nTotem + 4} tribe cards, which may include both character and event cards.
+      */
+     private List<TribeCard> upperListTribe;
+ 
+     /**
+      * The lower row of the tribe card. During the first round, there will be (num. of players + 1) character cards.
+      * During the following rounds, lower row will be emptied and populated with upper row's cards.
+      * When an Event card gets in the lower row, the event effect will be activated at the end of the round.
+      */
+     private List<TribeCard> lowerListTribe;
+ 
+     /** Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here. */
+     private List<BuildingCard> upperListBuilding;
+ 
+     /** Contains all the building cards of the lower list. When a new era starts, the old era's buildings are moved from the upper to the lower list. */
+     private List<BuildingCard> lowerListBuilding;
+ 
+     /**
+      * Returns the upper row of tribe cards.
+      *
+      * @return the live upper tribe card list.
+      */
+     public List<TribeCard> getUpperListTribe() { return upperListTribe; }
+ 
+     /**
+      * Returns the lower row of tribe cards.
+      *
+      * @return the live lower tribe card list.
+      */
+     public List<TribeCard> getLowerListTribe() { return lowerListTribe; }
+ 
+     /**
+      * Returns the upper row of building cards.
+      *
+      * @return the live upper building card list.
+      */
+     public List<BuildingCard> getUpperListBuilding() { return upperListBuilding; }
+ 
+     /**
+      * Returns the lower row of building cards.
+      *
+      * @return the live lower building card list.
+      */
+     public List<BuildingCard> getLowerListBuilding() { return lowerListBuilding; }
+ 
+     // TODO
+     private final ArrayList<List<BuildingCard>> buildingCardsAllEras;
+     /** Number of players */
+     private int nTotem;
+ 
+     /** Current era of the game */
+     private int era;
+ 
+     /**
+      * Creates and returns a new list containing the slots (tiles) of the game.
+      *
+      * @return a copy of the slot list.
+      */
+     public List<Slot> getSlotList(){
+         return slotList.stream().map(x->new Slot(x.getSlotId())).collect(Collectors.toList());
+     }
+ 
+     /**
+      * @return the size of the TribeDeck
+      */
+     public int getTribeDeckSize() {
+         return this.tribeDeck.size();
+     }
+ 
+     /**
+      * @return the game era
+      */
+     public int getEra() {return this.era;}
+ 
+ 
+     /**
+      *  Creates and initializes a new board:
+      *      - Generate the slotList using a method of DecksCreator.
+      *      - Generate the tribeDeck.
+      *      - Populate the lower list (if there is an event card, it's added to the upper list).
+      *      - Populate the upper list.
+      *      - Generate the buildingDeck using a method of DecksCreator.
+      *
+      * @param nTotem        the number of players.
+      */
+     public Board(int nTotem) {
+         this.nTotem = nTotem;
+         this.slotList = DecksCreator.loadSlotDeck().stream().filter(x->x.getNMinPlayer()<=nTotem).sorted(Comparator.comparingInt(Slot::getSlotId)).toList();
+         upperListTribe=new ArrayList<>();
+         lowerListTribe=new ArrayList<>();
+         lowerListBuilding=new ArrayList<>();
+         tribeDeck=generateTribeDeck(nTotem);
+         era=1;
+ 
+ 
+         for(int i=0;i<nTotem+1;i++)
+         {
+             TribeCard tempCard = tribeDeck.remove();
+             if(tempCard.isEventCard())
+             {
+                 upperListTribe.add(tempCard);
+                 i--;
+             }
+             else
+             {
+                 lowerListTribe.add(tempCard);
+             }
+         }
+ 
+         for(int i=upperListTribe.size();i<nTotem+4;i++)
+         {
+             TribeCard tempCard = tribeDeck.remove();
+             upperListTribe.add(tempCard);
+         }
+ 
+         ArrayList<BuildingCard> buildingDeck = new ArrayList<>(DecksCreator.loadBuildingDeckByEra(1));
+         Collections.shuffle(buildingDeck);
+         buildingCardsAllEras= new ArrayList<>();
+         buildingCardsAllEras.add(new ArrayList<>());
+         buildingCardsAllEras.add(new ArrayList<>());
+         buildingCardsAllEras.add(new ArrayList<>());
+         if(nTotem==2)
+         {
+             buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 1)));
+             upperListBuilding = new ArrayList<>(buildingDeck.subList(0,1));
+         }
+         else
+         {
+             buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 2)));
+             upperListBuilding = new ArrayList<>(buildingDeck.subList(0,2));
+         }
+ 
+         buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(2));
+         Collections.shuffle(buildingDeck);
+         if(nTotem<=3)
+         {
+             buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 2)));
+         }
+         else
+         {
+             buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));
+         }
+         buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(3));
+         Collections.shuffle(buildingDeck);
+         if(nTotem==2)
+         {
+             buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));
+         }else if(nTotem==5)
+         {
+             buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 5)));
+         }
+         else {
+             buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 4)));
+         }
+ 
+     }
+ 
+     /**
+      * Creates the tribeDeck. Loads the cards from each era, shuffle them, and then combine them in the final deck.
+      * In the end, two special events (Sustenance and ShamanicRitual) are added.
+      *
+      * @param nPlayers      the number of players.
+      * @return a queue containing the cards in this order:
+      *      - Era 1.
+      *      - Era 2.
+      *      - Era 3.
+      *      - Special events.
+      */
+     private Queue<TribeCard>  generateTribeDeck(int nPlayers) {
+         ArrayList<TribeCard> era1= DecksCreator.loadTribeDeckByEra(1).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));
+         ArrayList<TribeCard> era2= DecksCreator.loadTribeDeckByEra(2).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));
+         ArrayList<TribeCard> era3= DecksCreator.loadTribeDeckByEra(3).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));
+         Collections.shuffle(era1);
+         Collections.shuffle(era2);
+         Collections.shuffle(era3);
+ 
+         Queue<TribeCard> tribeDeck_temp=new LinkedList<>();
+         tribeDeck_temp.addAll(era1);
+         tribeDeck_temp.addAll(era2);
+         tribeDeck_temp.addAll(era3);
+         tribeDeck_temp.add(new Sustenance("095",3,3));
+         tribeDeck_temp.add(new ShamanicRitual("096",3,15,7));
+         return tribeDeck_temp;
+     }
+ 
+     /** @return the queue of events cards from the lower list that need to be activated */
+     public Queue<EventCard> getPendingEvents(){
+         return lowerListTribe.stream().filter(TribeCard::isEventCard).map(x->(EventCard)x).collect(Collectors.toCollection(LinkedList::new));
+     }
+ 
+     /**
+      * Take the selected card from the upper tribe list of the board.
+      *
+      * @param tribeCard is the card to remove.
+      * @return true if the card is succesfully removed.
+      */
+     public boolean removeUpperTribeCard(TribeCard tribeCard) {
+         return upperListTribe.remove(tribeCard);
+     }
+ 
+     /**
+      * Take the selected card from the lower tribe list of the board.
+      *
+      * @param tribeCard is the card to remove.
+      * @return true if succeed in removing the card.
+      */
+     public boolean removeLowerTribeCard(TribeCard tribeCard) {
+         return lowerListTribe.remove(tribeCard);
+     }
+ 
+     /**
+      * Take the selected card from the upper building list of the board.
+      *
+      * @param buildingCard is the card to remove.
+      * @return true if succeed in removing the card.
+      */
+     public boolean removeUpperBuildingCard(BuildingCard buildingCard) {
+         return upperListBuilding.remove(buildingCard);
+     }
+ 
+     /**
+      * Take the selected card from the lower building list of the board.
+      *
+      * @param buildingCard is the card to remove.
+      * @return true if succeed in removing the card.
+      */
+     public boolean removeLowerBuildingCard(BuildingCard buildingCard) {
+         return lowerListBuilding.remove(buildingCard);
+     }
+ 
+     /**
+      * Goes to the next round.
+      *      - Clear the lower tribe row.
+      *      - Moves the upper tribe row to the lower one.
+      *      - Populate the upper tribe row.
+      *
+      * @return the current era after moving to the next round.
+      */
+     public int nextRound() {
+         lowerListTribe.clear();
+         lowerListTribe.addAll(upperListTribe);
+         upperListTribe.clear();
+ 
+         for(int i=0;i<nTotem+4;i++)
+         {
+             if (tribeDeck.isEmpty()) break;
+             TribeCard tempCard = tribeDeck.remove();
+             if(tempCard.getEra()!=era)
+             {
+                 nextEra();
+             }
+             upperListTribe.add(tempCard);
+         }
+ 
+         return era;
+     }
+ 
+     /**
+      * Changes the era of the game:
+      *      - Increase the era attribute.
+      *      - Clear the lower building list and replace it with the upper building list.
+      *      - Repopulate the upper building list.
+      */
+     private void nextEra() {
+         era=era+1;
+         lowerListBuilding.clear();
+         lowerListBuilding.addAll(upperListBuilding);
+         upperListBuilding.clear();
+ 
+         if(era==2)
+         {
+             upperListBuilding.addAll(buildingCardsAllEras.get(1));
+         }
+         else
+         {
+             upperListBuilding.addAll(buildingCardsAllEras.get(2));
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-a/sources/source-2.html new file mode 100644 index 0000000..4629811 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/sources/source-2.html @@ -0,0 +1,339 @@ + + + + + + + + Coverage Report > CurrentState + + + + + + +
+ + +

Coverage Summary for Class: CurrentState (it.polimi.ingsw.gc14.Model.GamePackage)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
CurrentState + + 100% + + + (1/1) + + + + 93.3% + + + (14/15) + + + + 100% + + + (2/2) + + + + 64.3% + + + (27/42) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.GamePackage;
+ 
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Slot;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ /**
+  * Represents the current state of the game.
+  * A CurrentState object stores the current player, slot, era, round,
+  * remaining upper and lower cards, and the current game stage.
+  */
+ public class CurrentState implements Serializable {
+     // region Getters
+ 
+     /**
+      * The current player associated with the game state.
+      */
+     private Player player;
+ 
+     /**
+      * Returns the current player.
+      *
+      * @return the current player.
+      */
+     public Player getCurrentPlayer(){
+         return player;
+     }
+ 
+     /**
+      * The current slot associated with the game state.
+      */
+     private Slot slot;
+ 
+     /**
+      * Returns the current slot.
+      *
+      * @return the current slot.
+      */
+     public Slot getSlot(){
+         return slot;
+     }
+ 
+     /**
+      * The current era of the game.
+      */
+     private int era;
+ 
+     /**
+      * Returns the current era of the game.
+      *
+      * @return the current era of the game.
+      */
+     public int getEra(){
+         return era;
+     }
+ 
+     /**
+      * The current round of the game.
+      */
+     private int round;
+ 
+     /**
+      * Returns the current round of the game.
+      *
+      * @return the current round of the game.
+      */
+     public int getRound(){
+         return round;
+     }
+ 
+     /**
+      * The number of upper cards currently available.
+      */
+     private int nUpper;
+ 
+     /**
+      * Returns the number of upper cards currently available.
+      *
+      * @return the number of upper cards currently available.
+      */
+     public int getNUpper(){
+         return nUpper;
+     }
+ 
+     /**
+      * The number of lower cards currently available.
+      */
+     private int nLower;
+ 
+     /**
+      * Returns the number of lower cards currently available.
+      *
+      * @return the number of lower cards currently available.
+      */
+     public int getNLower(){
+         return nLower;
+     }
+ 
+     /**
+      * The current stage of the game.
+      */
+     private GameStages gameStage;
+ 
+     /**
+      * Returns the current stage of the game.
+      *
+      * @return the current stage of the game.
+      */
+     public GameStages getGameStage(){
+         return gameStage;
+     }
+ 
+     // endregion getters
+ 
+     // region Setters
+ 
+     /**
+      * Increments the current era by 1.
+      */
+     public void eraUpdate(){
+         era++;
+     }
+ 
+     /**
+      * Increments the current round by 1.
+      */
+     public void roundUpdate(){
+         round++;
+     }
+ 
+     /**
+      * Decrements the number of upper cards by 1.
+      */
+     public void upperDrawn(){
+         nUpper--;
+     }
+ 
+     /**
+      * Decrements the number of lower cards by 1.
+      */
+     public void lowerDrawn(){
+         nLower--;
+     }
+ 
+     /**
+      * Updates the current game stage.
+      *
+      * @param stage the new game stage.
+      */
+     public void gameStageUpdate(GameStages stage){
+         this.gameStage = stage;
+     }
+     // endregion setters
+ 
+     // region Constructors
+ 
+     /**
+      * Creates a new CurrentState object with default initial values.
+      * The initial player and slot are {@code null}, the era and round are set to 1,
+      * the number of upper and lower cards is set to 0, and the game stage is set to {@code WAITING}.
+      */
+     public CurrentState(){
+         this.player = null;
+         this.slot = null;
+         this.era = 1;
+         this.round = 1;
+         this.nUpper = 0;
+         this.nLower = 0;
+         this.gameStage = GameStages.WAITING;
+     }
+     // endregion constructors
+ 
+     // region Functions
+ 
+     /**
+      * Updates the current player, slot, and available draws.
+      * If {@code slot} is {@code null}, both {@link #nUpper} and {@link #nLower} are reset to 0.
+      * Otherwise they are set from the slot's values.
+      *
+      * @param player the new current player.
+      * @param slot the new current slot, or {@code null} when no slot is active.
+      */
+     public void playerUpdate(Player player, Slot slot){
+         this.player = player;
+         this.slot = slot;
+         if(slot == null){
+             this.nUpper = 0;
+             this.nLower = 0;
+         }
+         else{
+             this.nUpper = slot.getNUpper();
+             this.nLower = slot.getNLower();
+         }
+ 
+     }
+ 
+     // TODO
+     @Override
+     public String toString(){
+         var table= new AsciiTable(BorderStyle.ROUNDED,4);
+         List<String>header= new ArrayList<>();
+         header.add("Player");
+         header.add("Round");
+         header.add("Era");
+         header.add("GameStage");
+         table.addRow(header);
+         table.addSeparator();
+         List<String>values= new ArrayList<>();
+         values.add(player.getUserName());
+         values.add(Integer.toString(round));
+         values.add(Integer.toString(era));
+         values.add(gameStage.toString());
+         table.addRow(values);
+         return table.build();
+     }
+     // endregion functions
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-a/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-a/sources/source-3.html new file mode 100644 index 0000000..e4a11c7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-a/sources/source-3.html @@ -0,0 +1,173 @@ + + + + + + + + Coverage Report > GameStages + + + + + + +
+ + +

Coverage Summary for Class: GameStages (it.polimi.ingsw.gc14.Model.GamePackage)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
GameStages + + 100% + + + (1/1) + + + + 75% + + + (3/4) + + + + 91.7% + + + (11/12) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.GamePackage;
+ 
+ /**
+  * Represents the possible stages of a game.
+  */
+ public enum GameStages {
+ 
+      /**
+       * Stage in which the game is waiting for players to join.
+       */
+      WAITING("Waiting"),
+ 
+      /**
+       * Stage in which players choose their totems.
+       */
+      TOTEM_CHOICE("Totem"),
+ 
+      /**
+       * Stage in which players select their action slots.
+       */
+      SLOT_CHOICE("Slot"),
+ 
+      /**
+       * Stage in which the mandatory actions associated with the chosen slots are resolved.
+       */
+      RES_ACTIONS("Actions"),
+ 
+      /**
+       * Stage in which an optional card effect can be resolved.
+       */
+      OPT_CARD_E("Card Effect"),
+ 
+      /**
+       * Stage in which an event card is being resolved.
+       */
+      RES_EVENT("Event"),
+ 
+      /**
+       * Stage in which end-of-game scoring and ranking are computed.
+       */
+      ENDING("Ending"),
+ 
+      /**
+       * Stage indicating that the game has ended.
+       */
+      ENDED("Ended");
+ 
+      /** The human-readable name of this stage, used in {@link #toString()}. */
+      private final String displayName;
+ 
+      /**
+       * Constructs a {@code GameStages} value with the given display name.
+       *
+       * @param displayName the human-readable label for this stage
+       */
+      GameStages(String displayName) {
+           this.displayName = displayName;
+      }
+ 
+      /**
+       * Returns the human-readable name of this stage.
+       *
+       * @return the display name (e.g. {@code "Slot"} for {@code SLOT_CHOICE})
+       */
+      @Override
+      public String toString() {
+           return displayName;
+      }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index.html b/deliverables/Coverage/htmlReport/ns-b/index.html new file mode 100644 index 0000000..3798fdd --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..c180055 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..af23b61 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..1940cad --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..3b5dac0 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE.html new file mode 100644 index 0000000..c9ea600 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..db918b1 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..1cfb39c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..12222cb --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..21b4ae6 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,300 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Model.Orders + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Model.Orders

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Model.Orders + + 100% + + + (5/5) + + + + 100% + + + (17/17) + + + + 88.2% + + + (67/76) + + + + 96.5% + + + (111/115) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + + 100% + + + (7/7) + +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-b/sources/source-1.html new file mode 100644 index 0000000..1a69f8b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/sources/source-1.html @@ -0,0 +1,206 @@ + + + + + + + + Coverage Report > Order2 + + + + + + +
+ + +

Coverage Summary for Class: Order2 (it.polimi.ingsw.gc14.Model.Orders)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order2 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 83.3% + + + (15/18) + + + + 95.8% + + + (23/24) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Orders;
+ 
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.util.*;
+ import java.util.stream.IntStream;
+ 
+ /**
+  * Represents the order logic card used in a two-player game.
+  *
+  * <p>This class defines the specific turn-order behavior for games with
+  * two players.
+  */
+ public class Order2 extends OrderLogicCard  {
+ 
+     /**
+      * Creates an Order2 logic card for a two-player game.
+      *
+      * @param players the list of players associated with this order card.
+      * @throws NoSuchElementException if the number of players is not equal to 2.
+      */
+     public Order2(ArrayList<Player> players) throws NoSuchElementException {
+         super(players);
+         if(players.size()!=2)
+             throw new NoSuchElementException();
+     }
+ 
+     /**
+      * Applies the effect associated with the specified position index for the given player.
+      * <p>If {@code index == 0}, the player gains 1 Food and the building effect is applied.
+      * <p>If {@code index == 1}, the player tries to remove 1 Food; if the player cannot pay it,
+      * the player loses 2 Prestige.
+      *
+      * @param player the player to whom the effect is applied.
+      * @param index the position index of the effect to apply.
+      * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 2}.
+      */
+     @Override
+     protected void effect(Player player,int index) throws IndexOutOfBoundsException
+     {
+         if(index >= 2 || index < 0)
+         {
+             throw new IndexOutOfBoundsException("index out of bounds");
+         }
+         if(index==0)
+         {
+             player.addFood(1);
+             buildingEffect(player);
+             return;
+         }
+         if(index==1){
+             if(!player.removeFood(1)){
+                 player.removePrestige(2);
+             }
+         }
+     }
+ 
+     /**
+      * Creates the TURN ORDER box of the TUI.
+      * @return the string containing the box
+      */
+     @Override
+     public String toString()
+     {
+         var table = new AsciiTable(BorderStyle.ROUNDED, 2);
+         List<String> stringUp=new ArrayList<>();
+         for(int i=0;i<2;i++)
+         {
+             try {
+                 if(playerList.get(i).isPlayed())
+                     stringUp.add("");
+                 else
+                     stringUp.add(playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName());
+             }
+             catch (IndexOutOfBoundsException e) {
+                 stringUp.add("");
+             }
+         }
+         table.addRow(stringUp);
+ 
+         List<String> stringList=new ArrayList<>();
+         stringList.add("+1\uD83C\uDF56");
+         stringList.add("-1\uD83C\uDF56/-2\uD83C\uDFC5");
+         table.addRow(stringList);
+         return table.build() + "\n";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-b/sources/source-2.html new file mode 100644 index 0000000..6854c16 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/sources/source-2.html @@ -0,0 +1,214 @@ + + + + + + + + Coverage Report > Order3 + + + + + + +
+ + +

Coverage Summary for Class: Order3 (it.polimi.ingsw.gc14.Model.Orders)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order3 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 88.9% + + + (16/18) + + + + 96% + + + (24/25) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Orders;
+ 
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.NoSuchElementException;
+ 
+ /**
+  * Represents the order logic card used in a three-player game.
+  *
+  * <p>This class defines the specific turn-order behavior for games with
+  * three players.
+  */
+ public class Order3 extends OrderLogicCard {
+ 
+     /**
+      * Creates an Order3 logic card for a three-player game.
+      *
+      * @param players the list of players associated with this order card.
+      * @throws NoSuchElementException if the number of players is not equal to 3.
+      */
+     public Order3(ArrayList<Player> players) throws NoSuchElementException{
+         super(players);
+         if(players.size()!=3)
+             throw new NoSuchElementException();
+     }
+ 
+     /**
+      * Applies the effect associated with the specified position index for the given player.
+      * <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied.
+      * <p>If {@code index == 1}, no effect is applied.
+      * <p>If {@code index == 2}, the player tries to remove 1 Food; if the player cannot pay it,
+      * the player loses 2 Prestige.
+      *
+      * @param player the player to whom the effect is applied.
+      * @param index the position index of the effect to apply.
+      * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 3}.
+      */
+     @Override
+     protected void effect(Player player,int index) throws IndexOutOfBoundsException
+     {
+         if(index >= 3 || index < 0)
+         {
+             throw new IndexOutOfBoundsException("index out of bounds");
+         }
+         if(index==0)
+         {
+             player.addFood(2);
+             buildingEffect(player);
+             return;
+         }
+         if(index==2){
+             if(!player.removeFood(1)){
+                 player.removePrestige(2);
+             }
+         }
+     }
+ 
+     /**
+      * Creates the TURN ORDER box of the TUI.
+      * @return the string containing the box
+      */
+     @Override
+     public String toString()
+     {
+ 
+         var table = new AsciiTable(BorderStyle.ROUNDED, 3);
+ 
+         List<String> stringUp=new ArrayList<>();
+         for(int i=0;i<3;i++)
+         {
+             try {
+                 if(playerList.get(i).isPlayed())
+                     stringUp.add("");
+                 else
+                     stringUp.add(i + ". " + (playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName()));
+             }
+             catch (IndexOutOfBoundsException e) {
+                 stringUp.add("");
+             }
+         }
+         table.addRow(stringUp);
+ 
+         List<String> stringList=new ArrayList<>();
+ 
+         stringList.add("+2\uD83C\uDF56");
+         stringList.add("--");
+         stringList.add("-1\uD83C\uDF56/-2\uD83C\uDFC5");
+         table.addRow(stringList);
+ 
+ 
+         return table.build() + "\n";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-b/sources/source-3.html new file mode 100644 index 0000000..5f1ad3a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/sources/source-3.html @@ -0,0 +1,218 @@ + + + + + + + + Coverage Report > Order4 + + + + + + +
+ + +

Coverage Summary for Class: Order4 (it.polimi.ingsw.gc14.Model.Orders)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order4 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.6% + + + (28/29) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Orders;
+ 
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.NoSuchElementException;
+ 
+ /**
+  * Represents the order logic card used in a four-player game.
+  *
+  * <p>This class defines the specific turn-order behavior for games with
+  * four players.
+  */
+ public class Order4 extends OrderLogicCard {
+ 
+     /**
+      * Creates an Order4 logic card for a four-player game.
+      *
+      * @param players the list of players associated with this order card.
+      * @throws NoSuchElementException if the number of players is not equal to 4.
+      */
+     public Order4(ArrayList<Player> players)throws NoSuchElementException {
+         super(players);
+         if(players.size()!=4)
+             throw new NoSuchElementException();
+     }
+ 
+     /**
+      * Applies the effect associated with the specified position index for the given player.
+      * <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied.
+      * <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied.
+      * <p>If {@code index == 2}, no effect is applied.
+      * <p>If {@code index == 3}, the player tries to remove 1 Food; if the player cannot pay it,
+      * the player loses 2 Prestige.
+      *
+      * @param player the player to whom the effect is applied.
+      * @param index the position index of the effect to apply.
+      * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 4}.
+      */
+     @Override
+     protected void effect(Player player,int index) throws IndexOutOfBoundsException
+     {
+         if(index>=4 || index < 0)
+         {
+             throw new IndexOutOfBoundsException("index out of bounds");
+         }
+         if(index==0)
+         {
+             player.addFood(2);
+             buildingEffect(player);
+             return;
+         }
+         if(index==1)
+         {
+             player.addFood(1);
+             buildingEffect(player);
+             return;
+         }
+         if(index==3){
+             if(!player.removeFood(1)){
+                 player.removePrestige(2);
+             }
+         }
+     }
+ 
+     /**
+      * Creates the TURN ORDER box of the TUI.
+      * @return the string containing the box
+      */
+     @Override
+     public String toString()
+     {
+ 
+         var table = new AsciiTable(BorderStyle.ROUNDED, 4);
+         List<String> stringUp=new ArrayList<>();
+         for(int i=0;i<4;i++)
+         {
+             try {
+                 if(playerList.get(i).isPlayed())
+                     stringUp.add("");
+                 else
+                     stringUp.add(i + ". " + (playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName()));
+             }
+             catch (IndexOutOfBoundsException e) {
+                 stringUp.add("");
+             }
+         }
+         table.addRow(stringUp);
+ 
+         List<String> stringList=new ArrayList<>();
+         stringList.add("+2\uD83C\uDF56");
+         stringList.add("+1\uD83C\uDF56");
+         stringList.add("--");
+         stringList.add("-1\uD83C\uDF56/-2\uD83C\uDFC5");
+         table.addRow(stringList);
+         return table.build() + "\n";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-b/sources/source-4.html new file mode 100644 index 0000000..1393ca8 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/sources/source-4.html @@ -0,0 +1,220 @@ + + + + + + + + Coverage Report > Order5 + + + + + + +
+ + +

Coverage Summary for Class: Order5 (it.polimi.ingsw.gc14.Model.Orders)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
Order5 + + 100% + + + (1/1) + + + + 100% + + + (3/3) + + + + 90% + + + (18/20) + + + + 96.7% + + + (29/30) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Orders;
+ 
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
+ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.NoSuchElementException;
+ 
+ /**
+  * Represents the order logic card used in a five-player game.
+  *
+  * <p>This class defines the specific turn-order behavior for games with
+  * five players.
+  */
+ public class Order5 extends OrderLogicCard {
+ 
+     /**
+      * Creates an Order5 logic card for a five-player game.
+      *
+      * @param players the list of players associated with this order card.
+      * @throws NoSuchElementException if the number of players is not equal to 5.
+      */
+     public Order5(ArrayList<Player> players) throws NoSuchElementException{
+         super(players);
+         if(players.size()!=5)
+             throw new NoSuchElementException();
+     }
+ 
+     /**
+      * Applies the effect associated with the specified position index for the given player.
+      * <p>If {@code index == 0}, the player gains 3 Food and the building effect is applied.
+      * <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied.
+      * <p>If {@code index == 2}, no effect is applied.
+      * <p>If {@code index == 3}, no effect is applied.
+      * <p>If {@code index == 4}, the player tries to remove 1 Food; if the player cannot pay it,
+      * the player loses 2 Prestige.
+      *
+      * @param player the player to whom the effect is applied.
+      * @param index the position index of the effect to apply.
+      * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 5}.
+      */
+     @Override
+     protected void effect(Player player,int index) throws IndexOutOfBoundsException
+     {
+         if(index>=5 || index < 0)
+         {
+             throw new IndexOutOfBoundsException("index out of bounds");
+         }
+         if(index==0)
+         {
+             player.addFood(3);
+             buildingEffect(player);
+             return;
+         }
+         if(index==1)
+         {
+             player.addFood(1);
+             buildingEffect(player);
+             return;
+         }
+         if(index==4){
+             if(!player.removeFood(1)){
+                 player.removePrestige(2);
+             }
+         }
+     }
+ 
+     /**
+      * Creates the TURN ORDER box of the TUI.
+      * @return the string containing the box
+      */
+     @Override
+     public String toString()
+     {
+ 
+         var table = new AsciiTable(BorderStyle.ROUNDED, 5);
+         List<String> stringUp=new ArrayList<>();
+         for(int i=0;i<5;i++)
+         {
+             try {
+                 if(playerList.get(i).isPlayed())
+                     stringUp.add("");
+                 else
+                     stringUp.add(i + ". " + (playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName()));
+             }
+             catch (IndexOutOfBoundsException e) {
+                 stringUp.add("");
+             }
+         }
+         table.addRow(stringUp);
+ 
+         List<String> stringList=new ArrayList<>();
+         stringList.add("+3\uD83C\uDF56");
+         stringList.add("+1\uD83C\uDF56");
+         stringList.add("--");
+         stringList.add("--");
+         stringList.add("-1\uD83C\uDF56/-2\uD83C\uDFC5");
+         table.addRow(stringList);
+         return table.build() + "\n";
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-b/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-b/sources/source-5.html new file mode 100644 index 0000000..e281875 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-b/sources/source-5.html @@ -0,0 +1,176 @@ + + + + + + + + Coverage Report > OrderPlayer + + + + + + +
+ + +

Coverage Summary for Class: OrderPlayer (it.polimi.ingsw.gc14.Model.Orders)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
OrderPlayer + + 100% + + + (1/1) + + + + 100% + + + (5/5) + + + + 100% + + + (7/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Model.Orders;
+ 
+ import it.polimi.ingsw.gc14.Model.Player;
+ 
+ import java.io.Serializable;
+ 
+ /**
+  * Represents a player entry in an order logic card.
+  *
+  * <p>Each entry stores the player and whether that player has already
+  * performed an action in the current order sequence.
+  */
+ public class OrderPlayer implements Serializable {
+ 
+     /**
+      * The player associated with this order entry.
+      */
+     private final Player player;
+ 
+     /**
+      * Indicates whether the player has already played.
+      */
+     private boolean played;
+ 
+     /**
+      * Returns the player associated with this order entry.
+      *
+      * @return the player.
+      */
+     public Player getPlayer() {
+         return player;
+     }
+ 
+     /**
+      * Returns whether the player has already played in this order sequence.
+      *
+      * @return {@code true} if the player has played; {@code false} otherwise.
+      */
+     public boolean isPlayed() {
+         return played;
+     }
+ 
+     /**
+      * Marks this player as having played in the current order sequence.
+      */
+     public void markAsPlayed() {
+         this.played = true;
+     }
+ 
+     /**
+      * Creates an order entry for the specified player.
+      *
+      * @param player the player associated with this order entry.
+      * @param played {@code true} if the player has already played;
+      *               {@code false} otherwise.
+      */
+     public OrderPlayer(Player player, boolean played) {
+         this.player = player;
+         this.played = played;
+     }
+ 
+     /**
+      * Returns a string containing the player's username and whether the player
+      * has already played.
+      *
+      * @return the string containing the username and whether the player has played.
+      */
+     @Override
+     public String toString() {
+         return player.getUserName() + " " + played;
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index.html b/deliverables/Coverage/htmlReport/ns-c/index.html new file mode 100644 index 0000000..7ac373e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..97c0b6d --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..e2981ec --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..f1f8779 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..a00f77f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE.html new file mode 100644 index 0000000..9f25902 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..410b4fa --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..8a6bc20 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..7aedd9a --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..fdfaac3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,258 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network + + 0% + + + (0/4) + + + + 0% + + + (0/20) + + + + 0% + + + (0/28) + + + + 0% + + + (0/64) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + + 0% + + + (0/16) + +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/7) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-1.html new file mode 100644 index 0000000..a10fec2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-1.html @@ -0,0 +1,150 @@ + + + + + + + + Coverage Report > CompositeClientBroadcaster + + + + + + +
+ + +

Coverage Summary for Class: CompositeClientBroadcaster (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
CompositeClientBroadcaster + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/7) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
+ import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
+ 
+ /**
+  * Forwards every notification to both the RMI and the TCP transport layers.
+  *
+  * <p>This follows the Composite pattern: the caller interacts with a single
+  * broadcaster without knowing which protocols are active underneath.
+  */
+ public class CompositeClientBroadcaster {
+ 
+     private final RMIServer rmiServer;
+     private final TCPServer tcpServer;
+ 
+     /**
+      * Constructs a composite broadcaster backed by the given RMI and TCP servers.
+      *
+      * @param rmiServer the RMI server used to reach RMI clients.
+      * @param tcpServer the TCP server used to reach TCP clients.
+      */
+     public CompositeClientBroadcaster(RMIServer rmiServer, TCPServer tcpServer) {
+         this.rmiServer = rmiServer;
+         this.tcpServer = tcpServer;
+     }
+ 
+     /**
+      * Forwards the event to both the RMI and the TCP server.
+      * Each server is responsible for filtering error events to the
+      * requesting player only.
+      */
+     public void notifyAll(NetworkEvent event) {
+         rmiServer.notifyAll(event);
+         tcpServer.notifyAll(event);
+     }
+ 
+     /**
+      * Forwards the model snapshot to every client on both transports.
+      */
+     public void notifyAll(MiniModel model) {
+         rmiServer.notifyAll(model);
+         tcpServer.notifyAll(model);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-2.html new file mode 100644 index 0000000..3ae58c3 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-2.html @@ -0,0 +1,181 @@ + + + + + + + + Coverage Report > EventType + + + + + + +
+ + +

Coverage Summary for Class: EventType (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
EventType + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/16) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+  /**
+  * Represents the different types of network events that can be sent between
+  * client and server.
+  */
+ public enum EventType {
+ 
+      /**
+       * Event used to add a player to the game.
+       */
+      ADD_PLAYER("Add Player Event"),
+ 
+      /**
+       * Event used to submit a player's totem choice.
+       */
+      TOTEM_CHOICE("Totem Choice"),
+ 
+      /**
+       * Event used to submit a player's slot choice.
+       */
+      SLOT_CHOICE("Slot Choice"),
+ 
+      /**
+       * Event used to draw a tribe card from the upper card list.
+       */
+      DRAW_UPPER_TRIBE("Drawing Upper Tribe"),
+ 
+      /**
+       * Event used to draw a tribe card from the lower card list.
+       */
+      DRAW_LOWER_TRIBE("Drawing Lower Tribe"),
+ 
+      /**
+       * Event used to draw a building card from the upper card list.
+       */
+      DRAW_UPPER_BUILD("Drawing Upper Build"),
+ 
+      /**
+       * Event used to draw a building card from the lower card list.
+       */
+      DRAW_LOWER_BUILD("Drawing Lower Build"),
+ 
+      /**
+       * Event used to skip the current turn or optional action.
+       */
+      SKIP_TURN("Skip Turn"),
+ 
+      /**
+       * Event used to notify that a player has disconnected.
+       */
+      DISCONNECTED_PLAYER("Disconnected Player"),
+ 
+      /**
+       * Event used to notify that a player has reconnected.
+       */
+      RECONNECT_PLAYER("Reconnect Player"),
+ 
+      /**
+       * Event used to apply the transition to the next round.
+       */
+      NEXT_ROUND("Next Round"),
+ 
+      /**
+       * Event used to notify that the game has ended.
+       */
+      ENDED_GAME("Ended Game");
+ 
+      private final String description;
+      private EventType(String description) {
+          this.description = description;
+      }
+      @Override
+      public String toString() {
+          return description;
+      }
+  }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-3.html new file mode 100644 index 0000000..9e918ad --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-3.html @@ -0,0 +1,177 @@ + + + + + + + + Coverage Report > InterfaceResolver + + + + + + +
+ + +

Coverage Summary for Class: InterfaceResolver (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
InterfaceResolver + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/26) + + + + 0% + + + (0/22) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+ import java.net.*;
+ import java.util.Enumeration;
+ 
+ /** Utility class for resolving the local network interface to use when connecting to a server. */
+ public class InterfaceResolver {
+     private InterfaceResolver() {}
+ 
+     /**
+      * Returns the local IPv4 address that can reach the given server IP.
+      *
+      * <p>If the server is localhost, returns {@code "127.0.0.1"}.
+      * Otherwise iterates active non-loopback interfaces to find one on the same subnet;
+      * falls back to a UDP connect trick if no matching subnet is found.
+      *
+      * @param serverIp the server IP address or hostname.
+      * @return the local IP address string to use for outbound connections.
+      * @throws Exception if no suitable interface can be determined.
+      */
+     public static String resolveLocalInterface(String serverIp) throws Exception {
+         if (serverIp.equalsIgnoreCase("localhost") || serverIp.startsWith("127.") || serverIp.isEmpty()) {
+             return "127.0.0.1";
+         }
+ 
+         InetAddress serverAddr = InetAddress.getByName(serverIp);
+         Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
+         while (ifaces.hasMoreElements()) {
+             NetworkInterface ni = ifaces.nextElement();
+             if (!ni.isUp() || ni.isLoopback()) continue;
+ 
+             for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
+                 InetAddress localAddr = ia.getAddress();
+                 if (!(localAddr instanceof Inet4Address)) continue;
+ 
+                 int prefix = ia.getNetworkPrefixLength();
+                 if (sameSubnet(localAddr, serverAddr, prefix)) {
+                     return localAddr.getHostAddress();
+                 }
+             }
+         }
+ 
+         try (DatagramSocket socket = new DatagramSocket()) {
+             socket.connect(serverAddr, 9);
+             return socket.getLocalAddress().getHostAddress();
+         }
+     }
+     private static boolean sameSubnet(InetAddress a, InetAddress b, int prefix) {
+         if (prefix < 0 || prefix > 32) return false;
+         int maskBits = prefix == 0 ? 0 : (0xFFFFFFFF << (32 - prefix));
+         int addrA = toInt(a.getAddress()) & maskBits;
+         int addrB = toInt(b.getAddress()) & maskBits;
+         return addrA == addrB;
+     }
+     private static int toInt(byte[] bytes) {
+         return ((bytes[0] & 0xFF) << 24) |
+                 ((bytes[1] & 0xFF) << 16) |
+                 ((bytes[2] & 0xFF) <<  8) |
+                 (bytes[3] & 0xFF);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-4.html new file mode 100644 index 0000000..c9429ea --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-4.html @@ -0,0 +1,319 @@ + + + + + + + + Coverage Report > NetworkEvent + + + + + + +
+ + +

Coverage Summary for Class: NetworkEvent (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
NetworkEvent + + 0% + + + (0/1) + + + + 0% + + + (0/10) + + + + 0% + + + (0/2) + + + + 0% + + + (0/19) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Slot;
+ 
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+ 
+ /**
+  * Represents an event sent over the network.
+  *
+  * <p>A network event contains the information required to identify
+  * the requested action, determine whether it produced an error,
+  * and apply it either to the server-side {@link GameController}
+  * or to the client-side {@link MiniModel}.
+  */
+ public abstract class NetworkEvent implements Serializable {
+ 
+     /** The error type associated with this event; set when the event failed to apply. */
+     protected ErrorType errorType;
+ 
+     /**
+      * Returns the error type associated with this event.
+      *
+      * @return the error type, or {@code null} if no error occurred.
+      */
+     public ErrorType getErrorType() {
+         return errorType;
+     }
+     /**
+      * Username of the player requesting the event.
+      */
+     protected String username;
+ 
+     /**
+      * Returns the username of the player requesting the event.
+      *
+      * @return the username associated with the event.
+      */
+     public String getUsername() {
+         return username;
+     }
+ 
+     /**
+      * Type of the network event.
+      */
+     protected EventType eventType;
+ 
+     /**
+      * Map associating each occupied slot with the corresponding player.
+      */
+     protected Map<Slot, Player> slotPlayerMap;
+ 
+     /**
+      * Order logic card used to manage the player turn order.
+      */
+     protected OrderLogicCard orderLogicCard;
+ 
+     /**
+      * Current state of the game associated with the event.
+      */
+     protected CurrentState currentState;
+ 
+     /**
+      * List of all players.
+      */
+     protected List<Player> playerList;
+ 
+     /**
+      * Usernames of players currently disconnected from the game.
+      * Sent with every event so clients always have an up-to-date list.
+      */
+     protected ArrayList<String> disconnectedPlayers;
+ 
+     /**
+      * Populates this event with the current game state so clients can
+      * update their local model after receiving it.
+      * Subclasses that carry extra state (available totems, etc.) override
+      * this method and call {@code super} first.
+      *
+      * @param game                the current game model.
+      * @param disconnectedUsernames usernames of currently disconnected players.
+      */
+     public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames) {
+         setData(game.getSlotMap(), game.getOrderLogicCard(), game.getCurrentState(), game.getPlayers());
+     }
+ 
+     /**
+      * Sets the game data associated with this network event.
+      *
+      * @param slotPlayerMap the map associating each slot with the player occupying it.
+      * @param orderLogicCard the order logic card used to manage turn order.
+      * @param currentState the current state of the game.
+      * @param playerList the list of the actual state of the players
+      */
+     public void setData(Map<Slot, Player> slotPlayerMap,
+                         OrderLogicCard orderLogicCard,
+                         CurrentState currentState,
+                         List<Player> playerList) {
+         this.slotPlayerMap = slotPlayerMap;
+         this.orderLogicCard = orderLogicCard;
+         this.currentState = currentState;
+         this.playerList = playerList;
+     }
+ 
+     /**
+      * Returns the type of this event.
+      *
+      * @return the event type.
+      */
+     public EventType getEventType() {
+         return eventType;
+     }
+ 
+     /**
+      * Flag indicating whether the event could not be applied successfully.
+      */
+     protected boolean isError;
+ 
+     /**
+      * Returns whether the event represents an error.
+      *
+      * @return {@code true} if the event could not be applied successfully,
+      *         {@code false} otherwise.
+      */
+     public boolean isError() {
+         return isError;
+     }
+ 
+     /**
+      * Sets whether the event represents an error.
+      *
+      * @param isError {@code true} if the event could not be applied successfully,
+      *                {@code false} otherwise.
+      */
+     public void setIsError(boolean isError) {
+         this.isError = isError;
+     }
+ 
+     /**
+      * Overrides the error type for this event.
+      *
+      * @param errorType the error type to set.
+      */
+     public void setErrorType(ErrorType errorType) {
+         this.errorType = errorType;
+     }
+ 
+     /**
+      * Constructs a network event.
+      *
+      * @param username the username of the player requesting the event.
+      * @param eventType the type of the event.
+      * @param isError {@code true} if the event represents an error,
+      *                {@code false} otherwise.
+      */
+     protected NetworkEvent(String username, EventType eventType, boolean isError, ErrorType errorType) {
+         this.username = username;
+         this.eventType = eventType;
+         this.isError = isError;
+         this.errorType = errorType;
+     }
+ 
+     /**
+      * Returns a textual description of the event and its outcome.
+      *
+      * @return a string describing the event type and whether it represents an error.
+      */
+     @Override
+     public String toString() {
+         if (isError) {
+             return "ERROR: " + eventType;
+         } else {
+             return "ACTION: " + eventType;
+         }
+     }
+ 
+     /**
+      * Applies this event to the specified server-side game controller.
+      *
+      * @param gameController the game controller on which the event must be applied.
+      * @return {@code true} if the event is applied successfully,
+      *         {@code false} otherwise.
+      */
+     public abstract boolean apply(GameController gameController);
+ 
+     /**
+      * Applies this event to the specified client-side mini model.
+      *
+      * @param model the mini model on which the event must be applied.
+      * @return {@code true} if the event is applied successfully,
+      *         {@code false} otherwise.
+      */
+     public abstract boolean apply(MiniModel model);
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-5.html new file mode 100644 index 0000000..c9e5cf9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-5.html @@ -0,0 +1,89 @@ + + + + + + + + Coverage Report > NetworkConfig + + + + + + +
+ + +

Coverage Summary for Class: NetworkConfig (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + +
Class
NetworkConfig
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+ /** Shared network constants used by both server and client components. */
+ public final class NetworkConfig {
+     /** Port on which the RMI registry listens. */
+     public static final int  RMI_PORT            = 1099;
+     /** Port on which the TCP game server listens. */
+     public static final int  TCP_PORT            = 8080;
+     /** Port on which the TCP heartbeat server listens. */
+     public static final int  HEARTBEAT_PORT      = 8081;
+     /** Milliseconds of silence before a client is considered disconnected. */
+     public static final long SILENCE_THRESHOLD_MS  = 5_000;
+     /** Milliseconds between keep-alive pings sent by the client. */
+     public static final long KEEPALIVE_INTERVAL_MS = 3_000;
+     /** Minimum number of players required to start a game. */
+     public static final int  MIN_PLAYERS         = 2;
+     /** Maximum number of players allowed in a game. */
+     public static final int  MAX_PLAYERS         = 5;
+ 
+     private NetworkConfig() {}
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-c/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-c/sources/source-6.html new file mode 100644 index 0000000..09809de --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-c/sources/source-6.html @@ -0,0 +1,146 @@ + + + + + + + + Coverage Report > IClient + + + + + + +
+ + +

Coverage Summary for Class: IClient (it.polimi.ingsw.gc14.Network)

+ + + + + + + + + +
Class
IClient
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network;
+ 
+ import it.polimi.ingsw.gc14.ErrorType;
+ 
+ /**
+  * Defines the operations that a client can request during the game.
+  */
+ public interface IClient {
+ 
+     /**
+      * Connects the client to the server using the specified username
+      * and preferred connection type.
+      *
+      * @param username the username chosen by the player.
+      * @param proposedNPlayers the desired number of players proposed by this client.
+      * @return {@code true} if the connection is established successfully,
+      *         {@code false} otherwise.
+      */
+     ErrorType connect(String username, int proposedNPlayers);
+ 
+     /**
+      * Requests to draw a tribe card from the upper tribe card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the selected card in the upper tribe card list.
+      */
+     void drawUpperTribeCard(String playerUsername, int pos);
+ 
+     /**
+      * Requests to draw a tribe card from the lower tribe card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the selected card in the lower tribe card list.
+      */
+     void drawLowerTribeCard(String playerUsername, int pos);
+ 
+     /**
+      * Requests to draw a building card from the upper building card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the selected card in the upper building card list.
+      */
+     void drawUpperBuildingCard(String playerUsername, int pos);
+ 
+     /**
+      * Requests to draw a building card from the lower building card list.
+      *
+      * @param playerUsername the username of the player performing the action.
+      * @param pos the position of the selected card in the lower building card list.
+      */
+     void drawLowerBuildingCard(String playerUsername, int pos);
+ 
+     /**
+      * Requests to skip the current player's optional action.
+      *
+      * @param playerUsername the username of the player skipping the action.
+      */
+     void skipTurn(String playerUsername);
+ 
+     /**
+      * Requests to assign the specified player to a slot.
+      *
+      * @param playerUsername the username of the player making the slot choice.
+      * @param pos the position of the selected slot.
+      */
+     void slotChoice(String playerUsername, int pos);
+ 
+     /**
+      * Requests to assign the selected totem to the specified player.
+      *
+      * @param playerUsername the username of the player making the totem choice.
+      * @param totem the name of the selected totem.
+      */
+     void totemChoice(String playerUsername, String totem);
+ 
+     /** Notifies the server of a voluntary disconnection and closes the connection. */
+     void notifyDisconnection();
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index.html b/deliverables/Coverage/htmlReport/ns-d/index.html new file mode 100644 index 0000000..6bbfc28 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..adbafec --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..7da2516 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..bf108d4 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..fdcd712 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE.html new file mode 100644 index 0000000..03e168b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..165ca22 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..2de3011 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..a89b623 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..a4ad6a1 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,538 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.NetworkEvents + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.NetworkEvents

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.NetworkEvents + + 0% + + + (0/12) + + + + 0% + + + (0/41) + + + + 0% + + + (0/20) + + + + 0% + + + (0/175) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/12) + +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + + 0% + + + (0/19) + +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-1.html new file mode 100644 index 0000000..48dba63 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-1.html @@ -0,0 +1,184 @@ + + + + + + + + Coverage Report > AddPlayer + + + + + + +
+ + +

Coverage Summary for Class: AddPlayer (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
AddPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ /**
+  * Network event used to register a new player in the lobby.
+  *
+  * <p>The first player to join also proposes the desired number of players
+  * for the match. Subsequent joiners ignore {@code proposedNPlayer} if the
+  * game has already been created.
+  */
+ public class AddPlayer extends NetworkEvent {
+     /** Number of players proposed by this player; used only when creating a new game. */
+     private int proposedNPlayer;
+ 
+     /**
+      * @return the number of proposed players to add to the match
+      */
+     public int getProposedNPlayer() {
+         return proposedNPlayer;
+     }
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param proposedNPlayer the number of proposed players to add to the match
+      */
+     public AddPlayer(String username, int proposedNPlayer) {
+         super(username, EventType.ADD_PLAYER, false, ErrorType.GENERIC_ERROR);
+         this.proposedNPlayer = proposedNPlayer;
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could be added to the match, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController)
+     {
+         return gameController.addPlayer(username);
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, updating players,
+      * turn order, game state, and slot map.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-2.html new file mode 100644 index 0000000..4f7ebbf --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-2.html @@ -0,0 +1,200 @@ + + + + + + + + Coverage Report > ApplyNextRound + + + + + + +
+ + +

Coverage Summary for Class: ApplyNextRound (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
ApplyNextRound + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/19) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
+ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
+ import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Slot;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+ 
+ /**
+  * Network event that transitions all clients to the next round.
+  *
+  * <p>Carries refreshed card lists for all four board rows in addition
+  * to the standard game state (slot map, turn order, current state,
+  * player list). Only applied client-side; {@link #apply(GameController)}
+  * always returns {@code false}.
+  */
+ public class ApplyNextRound extends NetworkEvent {
+ 
+     private ArrayList<TribeCard> upperListTribeCards;
+     private ArrayList<TribeCard> lowerListTribeCards;
+     private ArrayList<BuildingCard> upperListBuildingCards;
+     private ArrayList<BuildingCard> lowerListBuildingCards;
+ 
+ 
+     /**
+      * Constructs an event that updates the game state for the next round.
+      *
+      * @param slotPlayerMap          the map associating each slot with the player occupying it.
+      * @param orderLogicCard         the order logic card that determines the player order.
+      * @param currentState           the current state of the game.
+      * @param players                the list of players in the game.
+      * @param upperListTribeCards    the upper row of tribe cards for the new round.
+      * @param lowerListTribeCards    the lower row of tribe cards for the new round.
+      * @param upperListBuildingCards the upper row of building cards for the new round.
+      * @param lowerListBuildingCards the lower row of building cards for the new round.
+      */
+     public ApplyNextRound(Map<Slot, Player> slotPlayerMap,
+                           OrderLogicCard orderLogicCard,
+                           CurrentState currentState,
+                           List<Player> players,
+                           ArrayList<TribeCard> upperListTribeCards,
+                           ArrayList<TribeCard> lowerListTribeCards,
+                           ArrayList<BuildingCard> upperListBuildingCards,
+                           ArrayList<BuildingCard> lowerListBuildingCards) {
+         super("SERVER", EventType.NEXT_ROUND, false, ErrorType.WRONG_ACTION);
+         setData(slotPlayerMap, orderLogicCard, currentState, players);
+         this.upperListBuildingCards = upperListBuildingCards;
+         this.lowerListBuildingCards = lowerListBuildingCards;
+         this.upperListTribeCards = upperListTribeCards;
+         this.lowerListTribeCards = lowerListTribeCards;
+     }
+ 
+     /**
+      * Not applicable server-side.
+      *
+      * @param gameController the game controller (unused).
+      * @return {@code false} always.
+      */
+     @Override
+     public boolean apply(GameController gameController) {
+         return false;
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, updating all board lists,
+      * slot map, turn order, and game state for the new round.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code true} always (this event cannot produce an error).
+      */
+     @Override
+     public boolean apply(MiniModel miniModel) {
+         synchronized (miniModel) {
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setPlayers(playerList);
+             miniModel.setUpperListTribeCards(upperListTribeCards);
+             miniModel.setLowerListTribeCards(lowerListTribeCards);
+             miniModel.setUpperListBuildingCards(upperListBuildingCards);
+             miniModel.setLowerListBuildingCards(lowerListBuildingCards);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-3.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-3.html new file mode 100644 index 0000000..754a538 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-3.html @@ -0,0 +1,193 @@ + + + + + + + + Coverage Report > DisconnectedPlayer + + + + + + +
+ + +

Coverage Summary for Class: DisconnectedPlayer (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
DisconnectedPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.Totems;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ /**
+  * Network event used to notify all clients that a player has disconnected.
+  *
+  * <p>Also carries the updated list of available totems, since a disconnection
+  * during totem selection may free a totem for other players.
+  */
+ public class DisconnectedPlayer extends NetworkEvent {
+     //TODO
+     private List<Totems> availableTotems;
+ 
+ 
+     @Override
+     public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames) {
+         super.enrichWithGameState(game, disconnectedUsernames);
+         this.availableTotems = game.getAvailableTotems();
+         this.disconnectedPlayers = disconnectedUsernames;
+     }
+ 
+     /**
+      * Constructs a disconnection event for the specified player.
+      *
+      * @param username the username of the player who disconnected.
+      */
+     public DisconnectedPlayer(String username) {
+         super(username, EventType.DISCONNECTED_PLAYER, false, ErrorType.GENERIC_ERROR);
+     }
+ 
+     /**
+      * Applies this disconnection event to the server-side game controller.
+      *
+      * @param gameController the game controller on which to apply the event.
+      * @return {@code true} if the disconnection is handled successfully.
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.disconnectedPlayer(username);
+     }
+ 
+     /**
+      * Applies this disconnection event to the client-side mini model,
+      * updating player data, turn order, game state, and disconnected player list.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setDisconnectedPlayers(disconnectedPlayers);
+             miniModel.setAvailableTotems(availableTotems);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ }
+ 
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-4.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-4.html new file mode 100644 index 0000000..8c4e2a5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-4.html @@ -0,0 +1,177 @@ + + + + + + + + Coverage Report > DrawLowerBuildingCard + + + + + + +
+ + +

Coverage Summary for Class: DrawLowerBuildingCard (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
DrawLowerBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ 
+ /**
+  * NetworkEvent to draw a building card from the lower card list.
+  */
+ public class DrawLowerBuildingCard extends NetworkEvent{
+     /** Index of the card to draw */
+     private int pos;
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param pos the index of the card to draw
+      */
+     public DrawLowerBuildingCard(String username, int pos){
+         super(username, EventType.DRAW_LOWER_BUILD, false, ErrorType.WRONG_ACTION);
+         this.pos = pos;
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could draw the card, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.drawLowerBuildingCard(username, pos);
+     }
+ 
+ 
+     /**
+      * Applies this event to the client-side mini model, removing the drawn card
+      * from the lower building list and updating players, turn order, game state, and slot map.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+ 
+             miniModel.removeLowerBuildingCard(pos);
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-5.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-5.html new file mode 100644 index 0000000..2bd8f86 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-5.html @@ -0,0 +1,176 @@ + + + + + + + + Coverage Report > DrawLowerTribeCard + + + + + + +
+ + +

Coverage Summary for Class: DrawLowerTribeCard (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
DrawLowerTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ 
+ /**
+  * NetworkEvent to draw a tribe card from the lower card list.
+  */
+ public class DrawLowerTribeCard extends NetworkEvent{
+ 
+     /** Index of the card to draw */
+     private int pos;
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param pos the index of the card to draw
+      */
+     public DrawLowerTribeCard(String username, int pos){
+         super(username, EventType.DRAW_LOWER_TRIBE, false, ErrorType.WRONG_ACTION);
+         this.pos = pos;
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could draw the card, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.drawLowerTribeCard(username, pos);
+     }
+     /**
+      * Applies this event to the client-side mini model, removing the drawn card
+      * from the lower tribe list and updating players, turn order, game state, and slot map.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+ 
+             miniModel.removeLowerTribeCard(pos);
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-6.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-6.html new file mode 100644 index 0000000..366f3f2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-6.html @@ -0,0 +1,176 @@ + + + + + + + + Coverage Report > DrawUpperBuildingCard + + + + + + +
+ + +

Coverage Summary for Class: DrawUpperBuildingCard (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
DrawUpperBuildingCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ 
+ /**
+  * NetworkEvent to draw a building card from the upper card list.
+  */
+ public class DrawUpperBuildingCard extends NetworkEvent{
+ 
+     /** Index of the card to draw */
+     private int pos;
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param pos the index of the card to draw
+      */
+     public DrawUpperBuildingCard(String username, int pos){
+         super(username, EventType.DRAW_UPPER_BUILD, false, ErrorType.WRONG_ACTION);
+         this.pos = pos;
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could draw the card, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.drawUpperBuildingCard(username, pos);
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, removing the drawn card
+      * from the upper building list and updating players, turn order, game state, and slot map.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+ 
+             miniModel.removeUpperBuildingCard(pos);
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-7.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-7.html new file mode 100644 index 0000000..7897173 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-7.html @@ -0,0 +1,176 @@ + + + + + + + + Coverage Report > DrawUpperTribeCard + + + + + + +
+ + +

Coverage Summary for Class: DrawUpperTribeCard (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
DrawUpperTribeCard + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/14) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ 
+ /**
+  * NetworkEvent to draw a tribe card from the upper card list.
+  */
+ public class DrawUpperTribeCard extends NetworkEvent{
+ 
+     /** Index of the card to draw */
+     private int pos;
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param pos the index of the card to draw
+      */
+     public DrawUpperTribeCard(String username, int pos){
+         super(username, EventType.DRAW_UPPER_TRIBE, false, ErrorType.WRONG_ACTION);
+         this.pos = pos;
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could draw the card, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.drawUpperTribeCard(username, pos);
+     }
+     /**
+      * Applies this event to the client-side mini model, removing the drawn card
+      * from the upper tribe list and updating players, turn order, game state, and slot map.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.removeUpperTribeCard(pos);
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-8.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-8.html new file mode 100644 index 0000000..7fba32c --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-8.html @@ -0,0 +1,173 @@ + + + + + + + + Coverage Report > EndedGame + + + + + + +
+ + +

Coverage Summary for Class: EndedGame (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Line, % +
EndedGame + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/12) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Model.OrderLogicCard;
+ import it.polimi.ingsw.gc14.Model.Player;
+ import it.polimi.ingsw.gc14.Model.Slot;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.util.ArrayList;
+ import java.util.Map;
+ 
+ /**
+  * Network event that signals the end of the game and delivers the final standings.
+  *
+  * <p>Only applied client-side; {@link #apply(GameController)} always returns {@code false}.
+  */
+ public class EndedGame extends NetworkEvent {
+ 
+     /**
+      * Constructs an event containing the final game state.
+      *
+      * @param slotPlayerMap  the map associating each slot with the player occupying it.
+      * @param orderLogicCard the order logic card that determines the player order.
+      * @param currentState   the current state of the game.
+      * @param players        the final list of players, used as the standings.
+      */
+     public EndedGame(Map<Slot, Player> slotPlayerMap,
+                      OrderLogicCard orderLogicCard,
+                      CurrentState currentState,
+                      ArrayList<Player> players) {
+         super("SERVER", EventType.ENDED_GAME, false, ErrorType.GENERIC_ERROR);
+         setData(slotPlayerMap, orderLogicCard, currentState, players);
+     }
+ 
+     /**
+      * Not applicable server-side.
+      *
+      * @param gameController the game controller (unused).
+      * @return {@code false} always.
+      */
+     @Override
+     public boolean apply(GameController gameController) {
+         return false;
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, updating the final
+      * game state and setting the standings list for the leaderboard.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code true} always (this event cannot produce an error).
+      */
+     @Override
+     public boolean apply(MiniModel miniModel) {
+         synchronized (miniModel) {
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setPlayers(playerList);
+             miniModel.setStandingPlayers(playerList);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-9.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-9.html new file mode 100644 index 0000000..0682351 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-9.html @@ -0,0 +1,184 @@ + + + + + + + + Coverage Report > ReconnectPlayer + + + + + + +
+ + +

Coverage Summary for Class: ReconnectPlayer (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ReconnectPlayer + + 0% + + + (0/1) + + + + 0% + + + (0/4) + + + + 0% + + + (0/2) + + + + 0% + + + (0/15) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.util.ArrayList;
+ 
+ /**
+  * Network event used to notify that a player has reconnected to the game.
+  */
+ public class ReconnectPlayer extends NetworkEvent {
+ 
+     @Override
+     public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames) {
+         super.enrichWithGameState(game, disconnectedUsernames);
+         this.disconnectedPlayers = disconnectedUsernames;
+     }
+ 
+     /**
+      * Constructs a reconnection event for the specified player.
+      *
+      * @param username the username of the player who reconnected.
+      */
+     public ReconnectPlayer(String username) {
+         super(username, EventType.RECONNECT_PLAYER, false, ErrorType.GENERIC_ERROR);
+     }
+ 
+     /**
+      * Applies the reconnection event to the server-side game controller.
+      *
+      * @param gameController the game controller on which to apply the event.
+      * @return {@code true} if the player reconnection is handled successfully,
+      *         {@code false} otherwise.
+      */
+     @Override
+     public boolean apply(GameController gameController) {
+         return gameController.reconnectPlayer(username);
+     }
+ 
+     /**
+      * Applies the reconnection update to the client-side mini model.
+      *
+      * <p>If the event does not represent an error, the player data,
+      * turn order, current game state, and slot assignments are updated.
+      *
+      * @param miniModel the mini model on which to apply the event.
+      * @return {@code true} if the update is applied successfully,
+      *         {@code false} if the event represents an error.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel) {
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setDisconnectedPlayers(disconnectedPlayers);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-a.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-a.html new file mode 100644 index 0000000..656ced9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-a.html @@ -0,0 +1,169 @@ + + + + + + + + Coverage Report > SkipTurn + + + + + + +
+ + +

Coverage Summary for Class: SkipTurn (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
SkipTurn + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/12) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ /**
+  * Network event used to skip the current player's optional card action.
+  */
+ public class SkipTurn extends NetworkEvent {
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      */
+     public SkipTurn(String username){
+         super(username, EventType.SKIP_TURN, false, ErrorType.WRONG_ACTION);
+     }
+ 
+     /**
+      * @param gameController the Game Controller on which to apply the event
+      * @return true if the player could skipTheTurn, false otherwise
+      */
+     @Override
+     public boolean apply(GameController gameController){
+         return gameController.skipTurn(username);
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, updating players,
+      * turn order, game state, and slot map after a skip turn action.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-b.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-b.html new file mode 100644 index 0000000..f88454b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-b.html @@ -0,0 +1,175 @@ + + + + + + + + Coverage Report > SlotChoice + + + + + + +
+ + +

Coverage Summary for Class: SlotChoice (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
SlotChoice + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/13) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ 
+ /**
+  * NetworkEvent to select a slot where to place the player totem.
+  */
+ public class SlotChoice extends NetworkEvent {
+ 
+     /** Index of the selected slot. */
+     private int pos;
+ 
+     /**
+      * Class constructor.
+      * Initializes all the attributes.
+      * @param username the name of the player requesting the event
+      * @param pos the index of the selected slot
+      */
+     public SlotChoice(String username, int pos) {
+         super(username, EventType.SLOT_CHOICE, false, ErrorType.WRONG_ACTION);
+         this.pos = pos;
+     }
+ 
+     /**
+      * @param gameController the game controller on which to apply the event.
+      * @return {@code true} if the slot choice is handled successfully, {@code false} otherwise.
+      */
+     @Override
+     public boolean apply(GameController gameController) {
+         return gameController.slotChoice(username, pos);
+     }
+ 
+     /**
+      * Applies this event to the client-side mini model, updating players,
+      * turn order, game state, and slot map after a slot selection.
+      *
+      * @param miniModel the client-side model to update.
+      * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel){
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-d/sources/source-c.html b/deliverables/Coverage/htmlReport/ns-d/sources/source-c.html new file mode 100644 index 0000000..7d6c931 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-d/sources/source-c.html @@ -0,0 +1,210 @@ + + + + + + + + Coverage Report > TotemChoice + + + + + + +
+ + +

Coverage Summary for Class: TotemChoice (it.polimi.ingsw.gc14.Network.NetworkEvents)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
TotemChoice + + 0% + + + (0/1) + + + + 0% + + + (0/5) + + + + 0% + + + (0/2) + + + + 0% + + + (0/17) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.NetworkEvents;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Model.Totems;
+ import it.polimi.ingsw.gc14.Network.EventType;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ 
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ /**
+  * Network event used to handle a player's totem choice.
+  */
+ public class TotemChoice extends NetworkEvent implements Serializable {
+ 
+     /**
+      * Name of the totem selected by the player.
+      */
+     private String totem;
+ 
+     /**
+      * List of totems still available after the choice has been processed.
+      */
+     private List<Totems> availableTotems;
+ 
+     /**
+      * Sets the list of currently available totems.
+      *
+      * @param availableTotems the totems still available for selection.
+      */
+     public void setAvailableTotems(List<Totems> availableTotems) {
+         this.availableTotems = availableTotems;
+     }
+ 
+     /**
+      * Constructs a totem choice event for the specified player.
+      *
+      * @param username the username of the player making the choice.
+      * @param totem    the name of the selected totem.
+      */
+     public TotemChoice(String username, String totem) {
+         super(username, EventType.TOTEM_CHOICE, false, ErrorType.WRONG_ACTION);
+         this.totem = totem;
+     }
+ 
+     @Override
+     public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames) {
+         super.enrichWithGameState(game, disconnectedUsernames);
+         this.availableTotems = game.getAvailableTotems();
+     }
+ 
+     /**
+      * Applies the totem choice event to the server-side game controller.
+      *
+      * @param gameController the game controller on which to apply the event.
+      * @return {@code true} if the totem choice is handled successfully,
+      *         {@code false} otherwise.
+      */
+     @Override
+     public boolean apply(GameController gameController) {
+         return gameController.totemChoice(username, totem);
+     }
+ 
+     /**
+      * Applies the totem choice update to the client-side mini model.
+      *
+      * <p>If the event does not represent an error, the player data,
+      * turn order, current game state, slot assignments, and available
+      * totems are updated.
+      *
+      * @param miniModel the mini model on which to apply the event.
+      * @return {@code true} if the update is applied successfully,
+      *         {@code false} if the event represents an error.
+      */
+     @Override
+     public boolean apply(MiniModel miniModel) {
+         synchronized (miniModel) {
+             if (isError)
+                 return false;
+ 
+             miniModel.setPlayers(playerList);
+             miniModel.setOrderLogicCard(orderLogicCard);
+             miniModel.setCurrentState(currentState);
+             miniModel.setSlotPlayerMap(slotPlayerMap);
+             miniModel.setAvailableTotems(availableTotems);
+             miniModel.setLastEvent(this);
+             return true;
+         }
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index.html b/deliverables/Coverage/htmlReport/ns-e/index.html new file mode 100644 index 0000000..f347661 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..dd2b73b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..a2f1024 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..0fc03bf --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..90e73e6 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE.html new file mode 100644 index 0000000..4e320f9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..e9167c7 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..b3a3742 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..213f4d9 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..554edf5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Client + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Client

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Client + + 0% + + + (0/2) + + + + 0% + + + (0/18) + + + + 0% + + + (0/14) + + + + 0% + + + (0/68) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-e/sources/source-1.html new file mode 100644 index 0000000..adf67ab --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/sources/source-1.html @@ -0,0 +1,179 @@ + + + + + + + + Coverage Report > ClientCallbackImpl + + + + + + +
+ + +

Coverage Summary for Class: ClientCallbackImpl (it.polimi.ingsw.gc14.Network.RMI.Client)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
ClientCallbackImpl + + 0% + + + (0/1) + + + + 0% + + + (0/3) + + + + 0% + + + (0/2) + + + + 0% + + + (0/8) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Client;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
+ import javafx.application.Platform;
+ 
+ import java.rmi.RemoteException;
+ import java.rmi.server.UnicastRemoteObject;
+ 
+ 
+ /**
+  * RMI client callback implementation of {@link IClientCallback}.
+  * Receives notifications from the server and updates the client game model.
+  */
+ public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCallback {
+ 
+     /** The client controller used to apply events and update the model */
+     private final ClientController clientController;
+ 
+ 
+     /**
+      * Class constructor.
+      * @param clientController the client controller
+      * @throws RemoteException if any RMI error occurs
+      */
+     public ClientCallbackImpl(ClientController clientController) throws RemoteException {
+         this.clientController = clientController;
+     }
+ 
+ 
+     /**
+      * Called by the server when the game is initialized.
+      * Sets the client game model in the {@link ClientController}.
+      * @param model the initialized {@link Game} model
+      * @throws RemoteException if any RMI error occurs
+      */
+     @Override
+     public void onGameInit(MiniModel model) throws RemoteException {
+         clientController.setModel(model);
+         clientController.getView().render();
+     }
+ 
+ 
+     /**
+      * Called by the server when an action has been accepted.
+      * If the event contains an error, it is printed to the console.
+      * Otherwise, the event is applied to the local model.
+      * @param event the {@link NetworkEvent} sent by the server
+      * @throws RemoteException if any RMI error occurs
+      */
+     @Override
+     public void onAction(NetworkEvent event) throws RemoteException {
+         if(event.isError()) {
+             clientController.getView().showError(event.getErrorType(),event.toString());
+         } else {
+             event.apply(clientController.getMiniModel());
+             clientController.getView().render();
+        }
+ 
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-e/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-e/sources/source-2.html new file mode 100644 index 0000000..c41b845 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-e/sources/source-2.html @@ -0,0 +1,380 @@ + + + + + + + + Coverage Report > RMIClient + + + + + + +
+ + +

Coverage Summary for Class: RMIClient (it.polimi.ingsw.gc14.Network.RMI.Client)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIClient + + 0% + + + (0/1) + + + + 0% + + + (0/15) + + + + 0% + + + (0/12) + + + + 0% + + + (0/60) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Client;
+ import java.rmi.RemoteException;
+ import java.rmi.registry.LocateRegistry;
+ import java.rmi.registry.Registry;
+ import java.util.concurrent.*;
+ 
+ import it.polimi.ingsw.gc14.Controller.ClientController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.Network.IClient;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
+ import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer;
+ 
+ /**
+  * Client RMI. Uses the methods exposed by the server RMI.
+  */
+ public class RMIClient  implements IClient {
+ 
+     private final String host;
+     private final int port;
+     private IGameServer stub;
+     private ClientController controller;
+     private String myIp;
+     private String username;
+ 
+     private volatile boolean running = false;
+ 
+     /** Scheduler that fires ping() every {@value NetworkConfig#KEEPALIVE_INTERVAL_MS} ms. */
+     private ScheduledExecutorService pingSender;
+     private ExecutorService executor;
+ 
+     /**
+      * Constructs an RMI client and initializes its connection parameters.
+      *
+      * @param controller the client controller associated with this RMI client.
+      * @param host       the hostname or IP address of the RMI server.
+      * @param port       the port used to connect to the RMI registry.
+      * @param myIp       the IP address of the client.
+      */
+     public RMIClient(ClientController controller, String host, int port, String myIp) {
+         this.controller = controller;
+         this.host = host;
+         this.port = port;
+         this.myIp = myIp;
+     }
+ 
+ 
+     /**
+      * Connects to the RMI server and starts the heartbeat loop.
+      *
+      * <p>Mirrors {@code TCPClient.connect()}: after a successful join the
+      * heartbeat channel is opened (here: a scheduler is started instead of
+      * opening a second socket).
+      */
+     @Override
+     public ErrorType connect(String username, int proposedNPlayers) {
+         try {
+             System.setProperty("java.rmi.server.hostname", this.myIp);
+             Registry registry = LocateRegistry.getRegistry(host, port);
+             this.stub = (IGameServer) registry.lookup("RMIGameServer");
+             this.username = username;
+ 
+             ClientCallbackImpl callback = new ClientCallbackImpl(controller);
+             ErrorType status = stub.joinGame(username, proposedNPlayers, callback);
+             if(status==null)
+             {
+                 running = true;
+                 startHeartbeat();
+                 return null;
+             }
+             return status;
+         } catch (Exception e) {
+             e.printStackTrace();
+             return ErrorType.GENERIC_ERROR;
+         }
+     }
+ 
+     // -------------------------------------------------------------------------
+     // Heartbeat — mirrors TCPClient.heartbeatLoop()
+     // -------------------------------------------------------------------------
+ 
+     /**
+      * Starts sending periodic pings to the server.
+      *
+      * <p>Mirrors the {@code ScheduledExecutorService} in
+      * {@code TCPClient.heartbeatLoop()} that writes {@code PING} every 3 s.
+      * On {@link RemoteException} the server is considered gone and
+      * {@link #disconnect()} is called — mirrors the behaviour on
+      * {@code SocketTimeoutException} / {@code IOException} in the TCP version.
+      */
+     private void startHeartbeat() {
+         pingSender = Executors.newSingleThreadScheduledExecutor(r -> {
+             Thread t = new Thread(r, "rmi-heartbeat");
+             t.setDaemon(true);
+             return t;
+         });
+ 
+         executor = Executors.newSingleThreadExecutor();
+         pingSender.scheduleAtFixedRate(() -> {
+             Future<?> future = executor.submit(() -> {
+                 try {
+                     stub.ping(username);
+                 } catch (RemoteException e) {
+                     disconnect();
+                     controller.getView().showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
+                 }
+             });
+             try {
+                 future.get(NetworkConfig.SILENCE_THRESHOLD_MS, TimeUnit.MILLISECONDS);
+             } catch (TimeoutException e) {
+                 future.cancel(true);
+                 controller.getView().showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
+                 disconnect();
+             } catch (Exception e) {
+                 disconnect();
+                 controller.getView().showError(ErrorType.SERVER_CRASHED,ErrorType.SERVER_CRASHED.toString());
+             }
+         }, 0, NetworkConfig.KEEPALIVE_INTERVAL_MS, TimeUnit.MILLISECONDS);
+     }
+ 
+     /**
+      * Tears down the connection.
+      * Mirrors {@code TCPClient.disconnect()}: stops the heartbeat and notifies
+      * the view.
+      */
+     private void disconnect() {
+         if (!running) return;
+         running = false;
+         if (pingSender != null) pingSender.shutdownNow();
+         if (executor != null) executor.shutdownNow();
+         controller.setModel(null);
+         controller.setClient(null);
+     }
+ 
+ 
+ 
+ 
+     /**
+      * Requests to draw a tribe card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperTribeCard(String playerUsername, int pos)  {
+         try{
+             stub.drawUpperTribeCard(playerUsername,pos);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote draw upper tribe card");
+         }
+     }
+ 
+ 
+     /**
+      * Requests to draw a tribe card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerTribeCard(String playerUsername,int pos)  {
+         try{
+             stub.drawLowerTribeCard(playerUsername,pos);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote draw lower tribe card");
+         }
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperBuildingCard(String playerUsername,int pos)  {
+         try{
+             stub.drawUpperBuildingCard(playerUsername,pos);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote draw upper building card");
+         }
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerBuildingCard(String playerUsername,int pos)  {
+         try{
+             stub.drawLowerBuildingCard(playerUsername,pos);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote draw lower building card");
+         }
+     }
+ 
+ 
+     /**
+      * Requests to skip the turn.
+      * This action is available only when the player cannot draw any tribe card, but still can buy some buildings.
+      * @param playerUsername the name of the player performing the action
+      */
+     public void skipTurn(String playerUsername) {
+         try{
+             stub.skipTurn(playerUsername);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote skip turn");
+         }
+     }
+     
+ 
+ 
+ 
+ 
+     /**
+      * Used to perform the slot choice action for the specified player at the specified position.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the selected slot
+      */
+     public void slotChoice(String playerUsername,int pos)  {
+         try{
+             stub.slotChoice(playerUsername,pos);
+         }
+         catch (RemoteException e){
+             System.out.println("Error during remote slot choice");
+         }
+     }
+     /**
+      * Sends a totem choice to the server for the specified player via RMI.
+      *
+      * @param playerUsername the username of the player choosing the totem.
+      * @param totem the name of the chosen totem.
+      */
+     public void totemChoice(String playerUsername,String totem)  {
+        try{
+            stub.totemChoice(playerUsername,totem);
+        }
+        catch (RemoteException e){
+            System.out.println("Error during remote totem choice");
+        }
+     }
+ 
+     /**
+      * Notifies the server of a voluntary disconnection via RMI, then stops
+      * the keep-alive scheduler.
+      */
+     public void notifyDisconnection() {
+         running = false;
+         if (pingSender != null) pingSender.shutdownNow();
+         if (executor != null) executor.shutdownNow();
+         try {
+             stub.disconnectPlayer(username);
+         } catch (RemoteException e) {
+             System.out.println("Error during remote disconnection");
+         }
+     }
+ 
+ 
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index.html b/deliverables/Coverage/htmlReport/ns-f/index.html new file mode 100644 index 0000000..e20131f --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK.html new file mode 100644 index 0000000..339280b --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK_DESC.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK_DESC.html new file mode 100644 index 0000000..8a3907e --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_BLOCK_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS.html new file mode 100644 index 0000000..0ff2db5 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS_DESC.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS_DESC.html new file mode 100644 index 0000000..16491e2 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_CLASS_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE.html new file mode 100644 index 0000000..200a359 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE_DESC.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE_DESC.html new file mode 100644 index 0000000..792f6ef --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_LINE_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD.html new file mode 100644 index 0000000..a716116 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD_DESC.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD_DESC.html new file mode 100644 index 0000000..097f812 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_METHOD_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_NAME_DESC.html b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_NAME_DESC.html new file mode 100644 index 0000000..0210f67 --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/index_SORT_BY_NAME_DESC.html @@ -0,0 +1,202 @@ + + + + + + Coverage Report > it.polimi.ingsw.gc14.Network.RMI.Server + + + + + + +
+ + + +

Coverage Summary for Package: it.polimi.ingsw.gc14.Network.RMI.Server

+ + + + + + + + + + + + + + + +
Package + Class, % + + Method, % + + Branch, % + + Line, % +
it.polimi.ingsw.gc14.Network.RMI.Server + + 0% + + + (0/2) + + + + 0% + + + (0/23) + + + + 0% + + + (0/36) + + + + 0% + + + (0/113) + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/sources/source-1.html b/deliverables/Coverage/htmlReport/ns-f/sources/source-1.html new file mode 100644 index 0000000..e1e13ba --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/sources/source-1.html @@ -0,0 +1,219 @@ + + + + + + + + Coverage Report > RMIHeartbeat + + + + + + +
+ + +

Coverage Summary for Class: RMIHeartbeat (it.polimi.ingsw.gc14.Network.RMI.Server)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIHeartbeat + + 0% + + + (0/1) + + + + 0% + + + (0/6) + + + + 0% + + + (0/4) + + + + 0% + + + (0/25) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Server;
+ 
+ import it.polimi.ingsw.gc14.LimitedMap;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer;
+ import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
+ 
+ import java.util.Map;
+ import java.util.concurrent.*;
+ 
+ /**
+  * Server-side heartbeat watchdog for a single RMI client.
+  *
+  * <p>Mirrors {@code HeartbeatHandler} used in the TCP stack, but adapted for RMI:
+  * instead of reading raw bytes from a dedicated socket, it relies on {@link #receivePing()}
+  * being called by {@link RMIServer#ping(String)} every time the client sends a ping.
+  *
+  * <p>If no ping is received within {@value NetworkConfig#SILENCE_THRESHOLD_MS} ms, the player is
+  * considered disconnected and {@link #disconnect()} is invoked, which:
+  * <ul>
+  *   <li>stops the watchdog;</li>
+  *   <li>marks the player as offline in {@code playerList};</li>
+  *   <li>removes the callback from {@code clients};</li>
+  *   <li>adds a {@link DisconnectedPlayer} event to the action queue.</li>
+  * </ul>
+  */
+ public class RMIHeartbeat {
+ 
+     private String username = "";
+     private final LimitedMap<String, Boolean> playerList;
+     private final Map<String, IClientCallback> clients;
+     private final BlockingQueue<NetworkEvent> actionQueue;
+ 
+     /** Last time a ping was received from this client. */
+     private volatile long lastPingTime = System.currentTimeMillis();
+     private volatile boolean running = true;
+ 
+     private final ScheduledExecutorService watchdog =
+             Executors.newSingleThreadScheduledExecutor(r -> {
+                 Thread t = new Thread(r, "rmi-watchdog-" + username);
+                 t.setDaemon(true);
+                 return t;
+             });
+ 
+     /**
+      * Constructs an RMI heartbeat handler for the specified client.
+      *
+      * @param username    the username of the client monitored by the heartbeat.
+      * @param playerList  the map storing the connection status of the players.
+      * @param clients     the collection of currently registered RMI clients.
+      * @param actionQueue the queue containing network events to be processed.
+      */
+     public RMIHeartbeat(
+             String username,
+             LimitedMap<String, Boolean> playerList,
+             Map<String, IClientCallback> clients,
+             BlockingQueue<NetworkEvent> actionQueue) {
+ 
+         this.username    = username;
+         this.playerList  = playerList;
+         this.clients     = clients;
+         this.actionQueue = actionQueue;
+     }
+ 
+     /** Called by {@link RMIServer} whenever it starts tracking this player. */
+     public void start() {
+         watchdog.scheduleAtFixedRate(() -> {
+             if (System.currentTimeMillis() - lastPingTime > NetworkConfig.SILENCE_THRESHOLD_MS) {
+                 System.out.println("RMI heartbeat timeout: " + username);
+                 disconnect();
+             }
+         }, 1, 1, TimeUnit.SECONDS);
+     }
+ 
+     /**
+      * Called by {@link RMIServer#ping(String)} each time the client pings.
+      * Resets the silence timer — mirrors writing {@code lastReceivedTime} in
+      * {@code HeartbeatHandler}.
+      */
+     public void receivePing() {
+         lastPingTime = System.currentTimeMillis();
+     }
+ 
+     /**
+      * Disconnects the monitored RMI client.
+      *
+      * <p>The heartbeat handler is stopped, the player is marked as offline,
+      * the associated RMI callback is removed, and a disconnection event is
+      * added to the action queue for server-side processing.
+      */
+     public void disconnect() {
+         if (!running) return;
+         running = false;
+         watchdog.shutdownNow();
+ 
+         playerList.put(username, false);
+ 
+         clients.remove(username);
+         actionQueue.add(new DisconnectedPlayer(username));
+         System.out.println("RMI disconnected: " + username);
+     }
+ }
+
+
+
+ + + + + + diff --git a/deliverables/Coverage/htmlReport/ns-f/sources/source-2.html b/deliverables/Coverage/htmlReport/ns-f/sources/source-2.html new file mode 100644 index 0000000..fec50ec --- /dev/null +++ b/deliverables/Coverage/htmlReport/ns-f/sources/source-2.html @@ -0,0 +1,490 @@ + + + + + + + + Coverage Report > RMIServer + + + + + + +
+ + +

Coverage Summary for Class: RMIServer (it.polimi.ingsw.gc14.Network.RMI.Server)

+ + + + + + + + + + + + + + + + + +
Class + Class, % + + Method, % + + Branch, % + + Line, % +
RMIServer + + 0% + + + (0/1) + + + + 0% + + + (0/17) + + + + 0% + + + (0/32) + + + + 0% + + + (0/88) + +
+ +
+
+ + +
+ package it.polimi.ingsw.gc14.Network.RMI.Server;
+ 
+ import it.polimi.ingsw.gc14.Controller.GameController;
+ import it.polimi.ingsw.gc14.ErrorType;
+ import it.polimi.ingsw.gc14.LimitedMap;
+ import it.polimi.ingsw.gc14.Model.Game;
+ import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
+ import it.polimi.ingsw.gc14.Model.MiniModel;
+ import it.polimi.ingsw.gc14.Network.NetworkConfig;
+ import it.polimi.ingsw.gc14.Network.NetworkEvent;
+ import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
+ import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
+ import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer;
+ 
+ import java.rmi.RemoteException;
+ import java.rmi.registry.LocateRegistry;
+ import java.rmi.registry.Registry;
+ import java.rmi.server.UnicastRemoteObject;
+ import java.util.ArrayList;
+ import java.util.Map;
+ import java.util.concurrent.BlockingQueue;
+ import java.util.concurrent.ConcurrentHashMap;
+ 
+ import java.rmi.*;
+ import java.util.stream.Collectors;
+ 
+ 
+ /**
+  * RMI server responsible for handling remote client connections,
+  * receiving player actions, and propagating game updates.
+  *
+  * <p>The server manages player registration, reconnection handling,
+  * heartbeat monitoring, and the forwarding of client requests to the
+  * shared network event queue.
+  */
+ public class RMIServer extends UnicastRemoteObject implements IGameServer {
+     private final String host;
+     private final GameController controller;
+     private Registry registry;
+     private final int nPort;
+ 
+     /** username → callback */
+     private final Map<String, IClientCallback> clients = new ConcurrentHashMap<>();
+ 
+     /**
+      * username → watchdog.
+      * One watchdog per connected player, mirrors {@code pendingHeartbeat} / per-socket
+      * HeartbeatHandler in the TCP stack.
+      */
+     private final Map<String, RMIHeartbeat> watchdogs = new ConcurrentHashMap<>();
+ 
+     private final BlockingQueue<NetworkEvent> actionQueue;
+     private final LimitedMap<String, Boolean> playerList;
+ 
+ 
+     /**
+      * Constructs an RMI server with the required game and network components.
+      *
+      * @param controller  the game controller used to manage the game logic.
+      * @param nPort       the port used by the RMI registry.
+      * @param actionQueue the queue containing incoming network events.
+      * @param playerList  the map storing the connection status of the players.
+      * @param host        the hostname or IP address exposed by the RMI server.
+      * @throws RemoteException if the remote object cannot be exported.
+      */
+     public RMIServer(GameController controller, int nPort,
+                      BlockingQueue<NetworkEvent> actionQueue,
+                      LimitedMap<String, Boolean> playerList,
+                      String host) throws RemoteException {
+         this.controller = controller;
+         this.nPort = nPort;
+         this.actionQueue = actionQueue;
+         this.playerList = playerList;
+         this.host = host;
+     }
+ 
+     // -------------------------------------------------------------------------
+     // Join
+     // -------------------------------------------------------------------------
+ 
+     /**
+      * {@inheritDoc}
+      *
+      * <p>After a successful join an {@link RMIHeartbeat} watchdog is created and
+      * started for the new player — mirrors creating a {@code HeartbeatHandler} in
+      * {@code TCPServer.acceptHeartbeat()}.
+      *
+      * @return {@code null} on success; an {@link it.polimi.ingsw.gc14.ErrorType} value on rejection.
+      */
+     @Override
+     public ErrorType joinGame(String username, int preferredInt, IClientCallback callback)
+             throws RemoteException {
+         if (preferredInt < NetworkConfig.MIN_PLAYERS || preferredInt > NetworkConfig.MAX_PLAYERS)
+             return ErrorType.WRONG_PLAYER_NUMBER;
+ 
+         synchronized (controller) {
+ 
+             if (playerList.isEmpty() && controller.getModel()==null) {
+                 controller.setModel(new Game(preferredInt));
+                 playerList.setLimit(preferredInt);
+                 System.out.println("Game Created With :"+preferredInt+" Players");
+             }
+             if(controller.getModel().getCurrentState().getGameStage()!= GameStages.WAITING ) {
+                 if (controller.getModel().getPlayers().stream().noneMatch(p -> p.getUserName().equals(username))|| controller.getModel().getCurrentState().getGameStage()==GameStages.ENDED) {
+                     return ErrorType.GAME_ALREADY_STARTED;
+                 }
+             }
+             else {
+                 if (controller.addPlayer(username)) {
+                     clients.put(username, callback);
+                     playerList.put(username, true);
+                     startWatchdog(username);
+                     System.out.println("Accepted player: " + username);
+                     return null;
+                 } else {
+                     return ErrorType.USERNAME_ALREADY_USED;
+                 }
+             }
+ 
+ 
+             if(!playerList.containsKey(username)){
+                 clients.put(username, callback);
+                 playerList.put(username, true);
+                 startWatchdog(username);
+                 System.out.println("(After crash)Reconnected player: " + username);
+                 return null;
+             }
+             else {
+                 if(!playerList.get(username))
+                 {
+                     playerList.put(username, true);
+                     clients.put(username, callback);
+                     System.out.println("Reconnected player: " + username);
+                     startWatchdog(username);
+                     Game game = controller.getModel();
+                     callback.onGameInit(new MiniModel(
+                             game.getSlotMap(), game.getOrderLogicCard(), game.getCurrentState(),
+                             game.getPlayers(), game.getAvailableTotems(),
+                             game.getUpperListTribeCards(), game.getLowerListTribeCards(),
+                             game.getUpperListBuilding(), game.getLowerListBuilding(),
+                             disconnectedUsernames(game)));
+                     System.out.println("Model sent: " + username);
+                     actionQueue.add(new ReconnectPlayer(username));
+                     return null;
+                 }
+                 else
+                     return ErrorType.USER_ALREADY_CONNECTED;
+             }
+         }
+     }
+ 
+     // -------------------------------------------------------------------------
+     // Heartbeat — called by RMIClient every ~3 s
+     // -------------------------------------------------------------------------
+ 
+     /**
+      * Receives a heartbeat ping from the client.
+      * Mirrors the server reading {@code PING} and replying {@code PONG} in
+      * {@code HeartbeatHandler.run()}.
+      *
+      * @param username the username of the pinging client.
+      */
+     @Override
+     public void ping(String username) throws RemoteException {
+         RMIHeartbeat wd = watchdogs.get(username);
+         if (wd != null) wd.receivePing();
+     }
+ 
+     // -------------------------------------------------------------------------
+     // Game model propagation — keep watchdogs in sync
+     // -------------------------------------------------------------------------
+ 
+     /**
+      * Notifies connected RMI clients of a new network event.
+      *
+      * <p>If the event does not represent an error, it is sent to all registered clients.
+      * If it represents an error, it is sent only to the client that requested the action.
+      * Communication errors are logged without interrupting the notification process.
+      *
+      * @param action the network event to send to the clients.
+      */
+     public void notifyAll(NetworkEvent action){
+         for (Map.Entry<String, IClientCallback> entry : clients.entrySet()) {
+             if (!action.isError() || action.getUsername().equals(entry.getKey())) {
+                 try{
+                     entry.getValue().onAction(action);
+                 }
+                 catch (RemoteException e)
+                 {
+                     System.out.println("Remote exception: Exception during action sending attempt " + e.getMessage());
+                 }
+             }
+         }
+     }
+ 
+     /**
+      * Notifies all connected RMI clients of a new game model.
+      *
+      * <p>The updated mini model is sent to each registered client callback.
+      * If a communication error occurs for a client, the exception is logged
+      * without interrupting the notification of the remaining clients.
+      *
+      * @param model the updated mini model to send to the connected clients.
+      */
+     public void notifyAll(MiniModel model) {
+         for (IClientCallback cb : clients.values()) {
+             try{
+                 cb.onGameInit(model);
+             }
+             catch (RemoteException e)
+             {
+                 System.out.println("Remote exception: Exception during model sending attempt " + e.getMessage());
+             }
+         }
+     }
+ 
+     /**
+      * Requests to draw a tribe card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperTribeCard(String playerUsername, int pos) {
+         actionQueue.offer(new DrawUpperTribeCard(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Requests to draw a tribe card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerTribeCard(String playerUsername,int pos) {
+         actionQueue.offer(new DrawLowerTribeCard(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the upper list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawUpperBuildingCard(String playerUsername,int pos) {
+         actionQueue.offer(new DrawUpperBuildingCard(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Requests to draw a building card from the lower list.
+      * Creates a NetworkEvent and sends it through the network client.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the card to draw
+      */
+     public void drawLowerBuildingCard(String playerUsername,int pos) {
+         actionQueue.offer(new DrawLowerBuildingCard(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Requests to skip the turn.
+      * This action is available only when the player cannot draw any tribe card, but still can buy some buildings.
+      * @param playerUsername the name of the player performing the action
+      */
+     public void skipTurn(String playerUsername) {
+         actionQueue.offer(new SkipTurn(playerUsername));
+     }
+ 
+ 
+ 
+     /**
+      * Used to perform the slot choice action for the specified player at the specified position.
+      * @param playerUsername the name of the player performing the action
+      * @param pos the index of the selected slot
+      */
+     public void slotChoice(String playerUsername,int pos) {
+         actionQueue.offer(new SlotChoice(playerUsername,pos));
+     }
+ 
+ 
+     /**
+      * Enqueues a totem choice event for the specified player.
+      *
+      * @param playerUsername the username of the player choosing the totem.
+      * @param totems the name of the chosen totem.
+      * @throws RemoteException if the RMI call fails.
+      */
+     public void totemChoice(String playerUsername, String totems) throws RemoteException {
+         actionQueue.offer(new TotemChoice(playerUsername,totems));
+     }
+ 
+ 
+     /**
+      * Starts the RMI server and binds it to the configured registry.
+      *
+      * <p>The method configures the server hostname, creates the RMI registry
+      * on the specified port, and registers this server instance under the
+      * {@code RMIGameServer} name.
+      *
+      * @return {@code true} if the server starts successfully,
+      *         {@code false} otherwise.
+      */
+     public boolean start() {
+         try {
+             System.setProperty("java.rmi.server.hostname", host);
+             registry = LocateRegistry.createRegistry(nPort);
+             registry.rebind("RMIGameServer", this);
+             System.out.println("RMI Server started on port: " + nPort);
+             return true;
+         } catch (RemoteException e) {
+             e.printStackTrace();
+             return false;
+         }
+     }
+ 
+     /**
+      * Stops the RMI server and removes its binding from the registry.
+      *
+      * <p>The remote server object is unexported, the registry entry associated
+      * with {@code RMIGameServer} is removed, and the server shutdown is logged.
+      *
+      * @return {@code true} if the server is stopped successfully,
+      *         {@code false} otherwise.
+      */
+     public boolean stop() {
+         try {
+             registry.unbind("RMIGameServer");
+             UnicastRemoteObject.unexportObject(this, true);
+             watchdogs.values().forEach(RMIHeartbeat::disconnect);
+             watchdogs.clear();
+             System.out.println("RMI Server stopped");
+             return true;
+         } catch (RemoteException | NotBoundException e) {
+             e.printStackTrace();
+             return false;
+         }
+     }
+ 
+ 
+     /**
+      * Creates and starts an {@link RMIHeartbeat} for the specified player.
+      *
+      * @param username the username of the player monitored by the heartbeat watchdog.
+      */
+     private void startWatchdog(String username) {
+         RMIHeartbeat wd = new RMIHeartbeat(
+                 username, playerList, clients, actionQueue);
+         watchdogs.put(username, wd);
+         wd.start();
+     }
+     /**
+      * Triggers a voluntary disconnection for the specified player
+      * by stopping their heartbeat watchdog.
+      *
+      * @param username the username of the player to disconnect.
+      */
+     @Override
+     public void disconnectPlayer(String username) {
+         RMIHeartbeat wd = watchdogs.get(username);
+         if (wd != null) wd.disconnect();
+     }
+ 
+     /** Returns usernames of players currently marked as disconnected in the given game. */
+     private static ArrayList<String> disconnectedUsernames(Game game) {
+         return game.getDisconnectedPlayers().entrySet().stream()
+                 .filter(Map.Entry::getValue)
+                 .map(e -> e.getKey().getUserName())
+                 .collect(Collectors.toCollection(ArrayList::new));
+     }
+ 
+ 
+ 
+ }
+
+
+
+ + + + + +